Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created July 3, 2019 10:37
Show Gist options
  • Save fclesio/2827f96e06ff9fb5f5350f217fdd0101 to your computer and use it in GitHub Desktop.
Save fclesio/2827f96e06ff9fb5f5350f217fdd0101 to your computer and use it in GitHub Desktop.
# Average songs per album
df_albuns = df_raw_lyrics.groupby(['artist', 'album']).size().reset_index()
df_albuns.columns = ['artist', 'album', 'qty_tracks']
df_albuns.groupby(['artist']).agg({'qty_tracks': [np.size, np.mean]}).reset_index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment