C.W.K.
Stream
Lesson 03 of 07 · published

Pandas DataFrame and Series — Labeled Tables

~12 min · pandas, dataframe, series

Level 0Curious Reader
0 XP0/47 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

What Pandas adds on top of NumPy

Pandas is the standard library for tabular data manipulation in Python. Current stable: Pandas 3.0.2 (March 2026). The 3.0 release in January 2026 was a major milestone — Copy-on-Write became the default, PyArrow-backed string types went mainstream, and a long list of legacy APIs got removed.

Where NumPy gives you typed numeric arrays, Pandas adds two things: labels (named columns and indexed rows) and heterogeneous types (string, datetime, categorical, all in the same table). That sounds boring; in practice it's the difference between "raw numbers" and "data you can actually work with."

The two core types

  • Series — a single labeled column. Conceptually a NumPy 1D array plus an index. Each DataFrame column is a Series.
  • DataFrame — a 2D labeled table. Columns can have different types; rows share an index.

Why labels matter

You almost never want to remember that revenue is column 7. You want to write df['revenue']. Labels also let Pandas align operations across DataFrames automatically — when you add two DataFrames, matching index/column labels line up; mismatches become NaN instead of silent bugs.

Code

Building DataFrames and Series from common sources·python
import pandas as pd

# 1. From a dict of lists (most common when constructing manually)
df = pd.DataFrame({
    'order_id':   ['A001', 'A002', 'A003'],
    'amount_usd': [120.50, 87.30, 215.00],
    'status':     ['shipped', 'pending', 'shipped'],
})

# 2. A single column is a Series
amounts = df['amount_usd']            # a Series
print(type(amounts).__name__)          # Series

# 3. Inspecting structure
print(df.shape)        # (3, 3)
print(df.dtypes)       # column types
print(df.head())       # first rows
print(df.describe())   # numeric summary

# 4. Selecting a single value (label-based)
print(df.loc[0, 'amount_usd'])         # 120.50

# 5. From a Parquet file (typical real-world entry point)
# df = pd.read_parquet('orders.parquet')

# 6. Use PyArrow-backed strings — faster + smaller in Pandas 3.x
df['status'] = df['status'].astype('string[pyarrow]')

External links

Exercise

Build a small DataFrame with three columns: order_id, amount_usd, and order_date. Then convert amount_usd to float64, order_date to datetime64[ns], and order_id to string[pyarrow]. Print df.dtypes before and after to feel the schema take shape.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.