Python for AILesson 5
Lesson 510 min
Pandas
Work with tables (DataFrames) — load, filter, and group data.
What you will learn
- ✓Loading data into a DataFrame
- ✓Selecting and filtering rows
- ✓Grouping and summarising
Explanation
Pandas gives you the DataFrame — a spreadsheet in code. It is where most real-world data work happens before modelling.
You can read a CSV, filter rows, create columns, and groupby to summarise — for example, average sales per region.
Getting comfortable here pays off more than almost any other skill, because real ML projects are mostly data preparation.
Code Example
python
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
Real-world use
Data scientists often spend 70-80% of a project in Pandas, cleaning and shaping data before any model is trained.
Common mistakes
- • Editing a filtered slice of a DataFrame and expecting the original to change (use .loc or .copy()).
Practice
Load any CSV, filter rows by one condition, and print the average of a numeric column.
Knowledge check
0/1 answered1. What is a Pandas DataFrame most like?
Answer all questions to check.