Last active
July 19, 2021 03:56
-
-
Save kaizer1v/885855d794b3ddea1b580206c05336dc to your computer and use it in GitHub Desktop.
Top 5 in every group - Pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data Columns available are = ['track', 'year', 'minutes_streamed'] | |
# GOAL: Top 5 tracks for every year from 2010 to 2020 based on the number of minutes streamed | |
group_1 = df.groupby(['year', 'track']).agg({'minutes_streamed': sum}) | |
group_1['minutes_streamed'].groupby(['year'], group_keys=False).nlargest(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment