LambdaLab
Informatics Practices · Class 12 · Python Pandas · DataFrame
PandasDataFrame⏱️ 6 min read

What is a DataFrame?

If a Series is a single labelled column, a DataFrame is the whole spreadsheet — a 2-dimensional table of rows and columns. It's the structure you'll use most in real data work.

1A table with two axes

A DataFrame stores an ordered collection of columns. It has two axes: the rows run along axis 0 and the columns along axis 1. Click around to see how each is picked out:

Anatomy of a DataFrame

A DataFrame is a table with TWO axes. Click a column header (axis 1) or a row label (axis 0) to see how each is selected.

axis 0 · rowsaxis 1 · columns
Name
English
IP
Maths
ID 1
Rinku658972
ID 2
Ritu778369
ID 3
Pankaj729587
ID 4
Ajay819994
ID 5
Aditya928796
what you selected
click a column header or a row label…

Every value has an address: (row index, column name)— e.g. Ajay's IP mark lives at ('ID 4', 'IP').

2What makes a DataFrame a DataFrame

  • 🧱 It's 2-dimensional — an ordered collection of columns.
  • 🌈 It's heterogeneous: different columns can hold different data types (text, ints, floats, booleans). But within one column the type is the same.
  • 🏷️ Both axes are labelled — row indexes and column names, which can be numbers, letters or strings.
  • ✏️ It's value-mutable and size-mutable — you can change values and add or drop rows and columns.

3A DataFrame is many Series

Here's the key mental model: a DataFrame is really several Series stacked side by side, all sharing the same row index. Each column is a Series.

Series vs DataFrame
SeriesDataFrame
Dimensions1-D (a column)2-D (rows × columns)
Axesjust the indexaxis 0 (rows) + axis 1 (columns)
Data typesone dtypeone per column (can differ)
Sizevalue-mutablevalue- & size-mutable

4Your first DataFrame

You import Pandas the same way, then build a DataFrame from a dictionary of columns. Run it and notice the row index on the left (0, 1, 2…) and the column names across the top.

first_dataframe.py
Key Takeaway
A DataFrame is a 2-D, labelled, heterogeneous table. Every value has an address: (row index, column name). Think of it as a bundle of Series sharing one index.
Quick Check

How many axes does a DataFrame have, and what are they?

Quick Check

Within a single DataFrame, can different columns have different data types?