Series and DataFrames
Pandas has two main objects: a Series (one column with labels) and a DataFrame (a whole table - many Series side by side).
A DataFrame is like an Excel sheet you control with code: rows, named columns, and an index. A Series is one column. Almost all pandas work is selecting, changing and summarising DataFrames, so getting comfortable with them is the first big step.
Example
Making a DataFrame
Example
First look at any table
Example
Columns
Example
df["price"] (one name) gives a Series. df[["product", "price"]] (a list) gives a DataFrame. The double brackets catch many beginners.Key points
- A Series is one labelled column; a DataFrame is a table.
- head(), shape and describe() give a first look.
- df["col"] is a Series; df[["a", "b"]] is a DataFrame.
📝 Test yourself
1. What is a DataFrame?
2. Which method shows count, mean, min and max of number columns?
3. Fill in the method that shows the first rows:
df.(3)
