Series & DataFrames

Pandas Basics

1 min read

Published Sep 29 2025, updated Aug 17 2026


21
0
0
0

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: 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





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 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      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 30print(df[df['Age'] > 30])





Key Differences

Feature

Series

DataFrame

Dimension

1D

2D

Structure

Single column with index

Multiple columns with index

Example

ages = pd.Series([25,30])

df = pd.DataFrame({...})

Use case

Single variable/column data

Tabular/multivariable data

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
Pandas Basics | Series & DataFrames | SimpleSteps.guide