Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to Polars

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

artist_means = (
    spotify_df
    # Group by artist and calculate average streams
    .group_by(____)
    .agg(____)
)

print(artist_means)
Code bewerken en uitvoeren