BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: Group & Aggregate

Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.

Module 2: Data Analytics

0/3 done
Exercises (0/3)
  • 1
    Sales per Region
    Context. A store manager has a table of orders, each tagged with a region. They want the total sales for each region. Your task. Write sales_per_region(df) that returns a pandas Series indexed by region, where each value is the sum of the amount column for that region. Example. Input df: | region | amount | | ------ | ------ | | North | 100 | | South | 50 | | North | 30 | Returns a Series: region North 130 South 50 Notes. - Region order in the result doesn't matter — we only compare keys → values. - Empty DataFrame → return an empty Series. - A region with only one order is still a valid group (its total is just that one value).
    7 min· 10 XP
  • 2
    Orders per Customer
    Context. An online store wants to know how many orders each customer placed. Your task. Write orders_per_customer(df) that returns a Series indexed by customer_id with the count of orders per customer. Example. Input rows (C1, O1), (C2, O2), (C1, O3) → Series {C1: 2, C2: 1}. Notes. Order of customers in the result doesn't matter. Empty DataFrame → empty Series.
    7 min· 10 XP
  • 3
    Average Rating per Genre
    Context. A reviews site wants the average rating for each movie genre. Your task. Write avg_rating_per_genre(df) that returns a Series indexed by genre, with the mean of the rating column for that genre. Example. Genre Action has ratings [4, 5] → entry Action: 4.5. Notes. Genre order in the result doesn't matter. A genre with one rating returns that rating as its mean. Empty DataFrame → empty Series.
    7 min· 10 XP