Named aggregations
A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.
The task
For each region, return a DataFrame with three columns: `total_revenue` (sum of revenue), `orders` (number of orders) and `avg_units` (mean units). Index by region.
What this exercise teaches
Named aggregation lets you pick the source column, the function and the output name in one place. Each keyword becomes a column of the result, in the order you write them.
A hint if you get stuck
agg accepts keyword arguments in the form new_name=("column", "function").
This exercise is part of Pro
Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.