~/learn/Pandas · Series & DataFrames
Series and DataFrames
The two containers everything else builds on.
why this matters
A DataFrame is a spreadsheet you control with code. Once your data is in one, cleaning and analysing it becomes repeatable.
A Series is a labelled one-dimensional array; a DataFrame is a table of Series sharing one index. You usually build one from a dict of columns or read one from a file.
Selecting one column with brackets gives a Series; a list of names gives a smaller DataFrame. Assigning to a new name adds a column.
Note
df.describe() and df.info() are the fastest way to get a feel for an unfamiliar table.
What a DataFrame is
DataFrame = table columns → each is a Series (one type) index → row labels on the left
Pro tip
Start every analysis with df.head(), df.shape and df.info() to see what you're working with.
key takeaways
- df.head() previews rows.
- df.shape gives (rows, columns).
- df["col"] is a Series.
check your understanding
df.shape returns (6, 8). What does that mean?
free practice
Build confidence with a question you can solve without Pro.