1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Polars

Connected

Exercise

Group-by aggregation

You want to analyze the Spotify streaming data to understand which artists are most popular. Start with a simple group-by operation and then refine it to control the output order.

The spotify_df DataFrame is available for you.

Instructions 1/2

undefined XP
  • 1
    • Group the spotify_df by the "artist" column and calculate the .mean() number of streams for each artist.
  • 2
    • Now modify the group-by operation to maintain the order of artists as they appear in the original DataFrame.