Learn / Pandas
Beginner

Series & DataFrames

The two core pandas structures, and what's actually inside a DataFrame.

A Series is a 1-D labeled array: think of it as a NumPy array with an index attached. A DataFrame is a 2-D table: a dict of Series that all share the same index, one per column.

MethodShowsExample

df.head(n) / df.tail(n)

first / last n rows

df.head(2) → the first 2 rows as a DataFrame

df.shape

(rows, columns)

a 3-row, 2-column DataFrame → (3, 2)

df.dtypes

the dtype of every column

{'age': dtype('int64'), 'name': dtype('O')}-style Series

df.describe()

count/mean/std/min/quartiles/max for numeric columns

one row per stat, one column per numeric field

df.info()

dtypes + non-null counts in one summary

prints column names, non-null counts, and dtypes

💡 Tip: df['col'] returns a Series (1-D); df[['col']] with double brackets returns a one-column DataFrame (2-D). The bracket style changes the result type.

Now practice it

Exercises that use what this lesson just covered.

← All Pandas lessonsSelection & Filtering