Series & DataFrames
Pandas Basics
1 min read
This section is 1 min read, full guide is 30 min read
Published Sep 29 2025, updated Aug 17 2026
21
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 listages = pd.Series([25, 30, 35, 40], index=['Alice', 'Bob', 'Charlie', 'David'])print(ages)Output:
Alice 25Bob 30Charlie 35David 40dtype: int64Explanation:
- 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']) # 30Pandas 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 dictionarydata = { 'Name': ['Alice', 'Bob', 'Charlie', 'David'], 'Age': [25, 30, 35, 40], 'City': ['New York', 'Los Angeles', 'Chicago', 'Houston']}df = pd.DataFrame(data)print(df)Output:
Name Age City0 Alice 25 New York1 Bob 30 Los Angeles2 Charlie 35 Chicago3 David 40 HoustonExplanation:
- 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 30print(df[df['Age'] > 30])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 |