What you'll build
Take the same CSV from the previous practice. Filter it, sort it, group it. Then write three plain-English findings.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Reuse the CSV from
practice-read-csvor pick a new one. - Filter the rows by a real condition (e.g.
df[df["price"] > 10]) and print the filtered count. - Sort by a column with
sort_valuesand print the top five rows after sorting. - Group by a category with
groupbyor count categories withvalue_counts. Print the result. - Write three short findings in plain English at the bottom of the notebook.
Bonus, if you're feeling brave
- Plot a single bar chart with matplotlib using the grouped result.
- Filter on two conditions joined with
&or|.
Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
slice_data.py
import pandas as pd
df = pd.read_csv("your-file.csv")
# 1. Filter
filtered = df[df["column_name"] > 0]
print("Filtered rows:", len(filtered))
# 2. Sort
top = df.sort_values("column_name", ascending=False).head()
print(top)
# 3. Group or value_counts
print(df["category_column"].value_counts())
# 4. Three findings (write them as comments or print them)How we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| Filter works | Filtered DataFrame really is smaller than the original. | 1 |
| Sort works | Top five rows are clearly ordered by the chosen column. | 1 |
| Group or count | `groupby` or `value_counts` produces a readable summary. | 1 |
| Findings are real | Your three sentences are backed by the numbers above them. | 1 |