Project 30: Top Customers Report
Data Analyst
Builds on these lessons
Current Task
Objective
Final challenge: combine reading, filtering, and aggregation — the full shape of a real reporting pipeline — to find your top customers.
Task: parse a CSV of orders, keep only completed ones, sum each customer's total (sorted descending), then print the totals and the top customer's name.
index.py
import pandas as pd
from io import StringIO
csv_text = "customer,order_total,status\nAna,120,completed\nLee,45,cancelled\nAna,80,completed\nMax,200,completed"
orders = pd.read_csv(StringIO(csv_text))
completed = orders[orders['status'] == 'completed']
totals = completed.groupby('customer')['order_total'].sum().sort_values(ascending=False)
print(totals)
print(totals.index[0])
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview
← Previous
Next →