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:
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.
Name | English | IP | Maths | |
|---|---|---|---|---|
ID 1 | Rinku | 65 | 89 | 72 |
ID 2 | Ritu | 77 | 83 | 69 |
ID 3 | Pankaj | 72 | 95 | 87 |
ID 4 | Ajay | 81 | 99 | 94 |
ID 5 | Aditya | 92 | 87 | 96 |
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 | DataFrame | |
|---|---|---|
| Dimensions | 1-D (a column) | 2-D (rows × columns) |
| Axes | just the index | axis 0 (rows) + axis 1 (columns) |
| Data types | one dtype | one per column (can differ) |
| Size | value-mutable | value- & 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.
How many axes does a DataFrame have, and what are they?
Within a single DataFrame, can different columns have different data types?