Day 19 of 30Real Python & Data
🐼Pandas — DataFrames
🎯 Today's objective
Load and explore tabular data like a spreadsheet in code.
📖 Key concepts
- DataFrame = rows × columns table
- pd.read_csv() loads data
- .head(), .info(), .describe()
- Select columns df["col"], filter df[df.col > x]
💻 Try this code
import pandas as pd
df = pd.DataFrame({"name": ["A","B","C"], "score": [88, 71, 95]})
print(df.head())
print(df["score"].mean())
print(df[df["score"] > 80])👥 Learn it your way
🧒 Young Explorers
Pandas is a spreadsheet you control with code — sort, filter, and total in one line.
Your task
Build a DataFrame of 4 students & marks; print the topper and the class average.
💼 Professionals
Learn indexing (loc/iloc), groupby, and handling missing values (NaN).
Your task
Load any CSV, group by a category, and compute mean of a numeric column.
🤖 AI connection
Real ML starts in Pandas: loading, cleaning, and shaping data into the rows/columns a model expects. ~80% of ML work is this data wrangling.
✅ Quick check
What does df.head() show?
The first few rows of the DataFrame.
How do you load a CSV?
pd.read_csv("file.csv")