BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/Group & Aggregate3/3
Exercise·7 min·10 XP

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:

regionamount
North100
South50
North30

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).
Previous
Replace Values with a Mapping
Next
Orders per Customer