Search⌘ K
AI Features

Challenge 5: Multiple Aggregations (Difficult)

Explore how to apply multiple aggregation functions simultaneously on grouped DataFrame columns using Pandas. Understand the use of .agg() with dictionaries to compute sum, mean, and max statistics by country, and learn how to flatten MultiIndex columns for easy access to the resulting data. By the end, you'll be able to convert grouped data into a nested dictionary format useful for analysis or reporting.

Problem definition

Your music analyst is interested in knowing multiple statistics at once, grouped by country.These are as follows:

  1. Sum of plays
  2. Average of plays
  3. Maximum fans from all artists in the country
...