Kiks & Learn
Start learning ↗
Python / Intermediate

Pandas: explore real-world data

Explore tabular data with pandas: load a CSV, inspect its columns, filter and group records, and make a careful plan for missing values.

YOUR FREE LEARNING PATH

Learn it here, one small step at a time.

4 guided lessons · About 2h 30m including practice · No subscription

  • Load and inspect a DataFrame
  • Filter rows and create group summaries
  • Handle missing data without hiding its meaning

Recommended first: Python: your first practical programs. These foundations are suggestions, not a requirement to begin.

regionitemamountNorthNotebook$12SouthPen$10NorthFolder$15filter rows → group → summarize
A table being filtered and grouped into a summary
4 lessons · FreeOptional official free reference ↗
LESSON 01 / 30 MINUTES

Load a table and check its shape

Pandas is a Python library for working with tables. A DataFrame has rows and columns. Load a CSV with pd.read_csv("sales.csv"), then inspect df.head(), df.shape, and df.dtypes. These tell you what a few rows look like, how large the table is, and how Python interpreted each column.

First ask what one row represents. A revenue average per transaction means something different from an average per customer. Keep a copy of the source file and check for unexpected headers or dates.

Useful first checks
CommandWhat it tells you
`df.head()`A few example records
`df.shape`Number of rows and columns
`df.dtypes`How each column is stored
`df.isna().sum()`Missing values in each column
TRY IT YOURSELF

Load a sample CSV and write down its row count, columns, and what one row means. If a date looks like text, inspect it before converting it.

Reveal a suggested answer

A numeric-looking column may have been loaded as text, or may contain values that need careful conversion.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 02 / 30 MINUTES

Select and filter the rows you need

A filter keeps rows that match a condition. For example, df.loc[df["region"] == "North", ["item", "amount"]] selects two columns for North. Combine conditions with & or |, and put each condition in parentheses. Use .loc to make row and column selection clear.

Check how many rows remain after filtering. If the result is empty, check spelling, spaces, casing, and the meaning of your condition.

Filter examples
QuestionPattern
North only`df.loc[df["region"] == "North"]`
Amounts at least 10`df.loc[df["amount"] >= 10]`
North and amount at least 10`(region_is_north) & (amount_is_at_least_10)`
TRY IT YOURSELF

Filter your table to show North-region sales with amount 10 or more. Print the number of matching rows and compare it with the original.

Reveal a suggested answer

The parentheses make each comparison happen before the `&` or `|`, avoiding ambiguous operator order.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 03 / 30 MINUTES

Group rows to answer a question

groupby makes summaries at a chosen level. For example, df.groupby("region")["amount"].sum() calculates a total per region. Use .agg() for several measurements, such as sum and count. Decide the grouping columns before interpreting an average or total.

A grouped table is not the original detail. Keep the detail available so you can trace a surprising summary back to its records.

Pick the summary you need
QuestionGroupingCalculation
Total per region`region`sum of amount
Number of sales per region`region`count of sale IDs
Average per item and region`region`, `item`mean of amount
TRY IT YOURSELF

Calculate total amount and number of sales per region. Which region has the larger total? Does it also have more transactions?

Reveal a suggested answer

Yes. Fewer transactions may have larger amounts, so total and count answer different questions.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 04 / 30 MINUTES

Handle missing values with care

A missing value is not automatically zero. Check where values are missing with df.isna().sum() and compare missingness across important columns. Ask whether the value was unknown, not collected, or not applicable. Document your choice before dropping or filling anything.

For a practice copy only, you could keep incomplete rows visible with df[df["amount"].isna()]. If you decide to exclude rows from one metric, report how many were excluded and why.

Three different meanings
Data valuePossible meaningQuestion to ask
Missing amountNot recordedCan the source be checked?
Amount = 0No sale amountIs zero a valid measured value?
Missing regionArea unknownShould unknown remain a visible group?
TRY IT YOURSELF

Find rows with a missing amount. Count them. Decide whether your report can use those rows and describe the limitation rather than silently replacing them with zero.

Reveal a suggested answer

It adds a real zero to the calculation, even though the true amount is unknown; the result can be biased.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

KEEP BUILDING

Recommended next steps

These paths build on ideas from this course. You can start any of them whenever you are ready.

CHECK YOUR UNDERSTANDING

Your final knowledge check.

Score 80% or more to pass. Sign in to save your best result.

1. Should missing revenue always become zero?
2. How should you finish this learning path?

Sign in and start tracking this course to submit and save your score. Use each lesson’s self-check to practice without an account.

Learn together

Sign in to leave a comment →