Series & DataFrames
Pandas Basics
1 min read
This section is 1 min read, full guide is 29 min read
Published Sep 29 2025, updated Sep 30 2025
20
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
PandasPython
Pandas Series
A Series is a one-dimensional labeled array. Think of it as a column of data with indexes (labels).
Example:
# Create a Series from a list
ages = pd.Series([25, 30, 35, 40], index=['Alice', 'Bob', 'Charlie', 'David'])
print(ages)
Copy to Clipboard
Toggle show comments
Output:
Alice 25
Bob 30
Charlie 35
David 40
dtype: int64
Explanation:
- The values are
[25, 30, 35, 40]
. - The index (labels) are
['Alice', 'Bob', 'Charlie', 'David']
. - You can access elements by index label:
print(ages['Bob'])
# 30
Copy to Clipboard
Toggle show comments
Pandas DataFrame
A DataFrame is a two-dimensional table — like a spreadsheet or SQL table. It has rows and columns, where each column can be a Series.
Example:
# Create a DataFrame from a dictionary
data = {
'Name': ['Alice', 'Bob', 'Charlie', 'David'],
'Age': [25, 30, 35, 40],
'City': ['New York', 'Los Angeles', 'Chicago', 'Houston']
}
df = pd.DataFrame(data)
print(df)
Copy to Clipboard
Toggle show comments
Output:
Name Age City
0 Alice 25 New York
1 Bob 30 Los Angeles
2 Charlie 35 Chicago
3 David 40 Houston
Explanation:
- Each column is like a Pandas Series:
df['Age']
gives the age column. - You can access rows by index:
df.loc[1]
gives Bob’s row. - You can filter or manipulate data easily:
# All people older than 30
print(df[df['Age'] > 30])
Copy to Clipboard
Toggle show comments
Key Differences
Feature | Series | DataFrame |
Dimension | 1D | 2D |
Structure | Single column with index | Multiple columns with index |
Example |
|
|
Use case | Single variable/column data | Tabular/multivariable data |