Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- regions = ['na_sales', 'jp_sales', 'eu_sales']
- for i in range(3):
- top_platforms = (df_period.groupby('platform')[regions[i]].sum().
- reset_index().
- sort_values(regions[i], ascending = False, ignore_index = True).
- head(5))
- top_platforms = (top_platforms.
- append({
- 'platform': 'Other_platform',
- regions[i]: df_period[regions[i]].sum() - top_platforms[regions[i]].sum()},
- ignore_index= True))
- import matplotlib.pyplot as plt
- fig, ax = plt.subplots(1,3)
- ax[i].pie(top_platforms[regions[i]], labels = top_platforms['platform'], autopct="%1.1f%%", frame = True)
- ax[i].axis('equal')
- ax[i].set_title(top_platforms.columns[i].split(' ')[0].upper())
- plt.show()
Add Comment
Please, Sign In to add comment