AssignmentsWeek 03 · Data and the outside worldSlice the data — filter, sort, group
wk03.p2Practice exerciseWeek 03 · Data and the outside worldOpen · due in week 3

Slice the data — filter, sort, group

Take the same CSV from the previous practice. Filter it, sort it, group it. Then write three plain-English findings.

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.

  1. Reuse the CSV from practice-read-csv or pick a new one.
  2. Filter the rows by a real condition (e.g. df[df["price"] > 10]) and print the filtered count.
  3. Sort by a column with sort_values and print the top five rows after sorting.
  4. Group by a category with groupby or count categories with value_counts. Print the result.
  5. 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.

CheckWhat we look forPt
Filter worksFiltered DataFrame really is smaller than the original.1
Sort worksTop five rows are clearly ordered by the chosen column.1
Group or count`groupby` or `value_counts` produces a readable summary.1
Findings are realYour three sentences are backed by the numbers above them.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →