Data Science · Level 3 Project

Project: Clean a Messy CSV with pandas

Clean a real-looking export (duplicated orders, prices as text, messy status labels, date strings) and report the revenue of each month.

  • Cleaning steps in a fixed order
  • Text to numbers and dates
  • Grouping the clean data

Real exports mix every problem at once. Clean in a fixed order (duplicates, labels, numbers, dates) and only then compute. Trap: totals computed before removing duplicates count those orders twice.

df = df.drop_duplicates(subset=["order_id"]).copy()
df["status"] = df["status"].str.strip().str.lower()
df = df[df["status"] == "paid"].copy()

Write monthly_revenue(df) that removes duplicate order_ids, keeps the orders whose status is "paid" in any case or spacing, parses price (like "$1,200.50") and date, and returns a dict of total revenue per month number, for example {1: 1250.5, 2: 50.0}.

solution.py
Test Suites Pending
Output