StudyAIStudyAI
Pro
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
import pandas as pd
2
 
3
df = pd.read_csv('sales.csv')
4
top = df[df['amount'] > 1000]
5
by_region = df.groupby('region')['amount'].mean()
6
print(by_region)
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 answered

1. What is a Pandas DataFrame most like?

Answer all questions to check.