1. 学习
  2. /
  3. 课程
  4. /
  5. Introduction to Polars

Connected

练习

Pivoting a DataFrame

You want to convert the Spotify data from long format to wide format in order to compare the number of streams for each artist in each year.

The spotify_df DataFrame is available for you and has been modified to get the number of streams for each artist in each year in artist_year_df.

说明 1 / 共 2 个

undefined XP
  • 1
    • Pivot artist_year_df to get the "artist" on each row, the "year" for each column, and the "streams" values.
  • 2
    • Pivot spotify_df directly where we aggregate by calculating the mean number of streams per artist per year.