Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
25
Indexable
Never
genre_na = (gm_act.pivot_table(index = 'genre', values = 'na_sales', aggfunc = 'sum')\
.sort_values(by = 'na_sales', ascending = False).reset_index().loc[:4])
sum_p = (gm_act.pivot_table(index = 'genre', values = 'na_sales', aggfunc = 'sum')
.sort_values(by ='na_sales', ascending = False).iloc[5:].sum()[0])
genre_na.loc[5] = ['Другие жанры', sum_p]
genre_na


genre_eu = (gm_act.pivot_table(index = 'genre', values = 'eu_sales', aggfunc = 'sum')\
.sort_values(by = 'eu_sales', ascending = False).reset_index().loc[:4])
sum_p = (gm_act.pivot_table(index = 'genre', values = 'eu_sales', aggfunc = 'sum')
.sort_values(by ='eu_sales', ascending = False).iloc[5:].sum()[0])
genre_eu.loc[5] = ['Другие жанры', sum_p]
genre_eu


genre_jp = (gm_act.pivot_table(index = 'genre', values = 'jp_sales', aggfunc = 'sum')\
.sort_values(by = 'jp_sales', ascending = False).reset_index().loc[:4])
sum_p = (gm_act.pivot_table(index = 'genre', values = 'jp_sales', aggfunc = 'sum')
.sort_values(by ='jp_sales', ascending = False).iloc[5:].sum()[0])
genre_jp.loc[5] = ['Другие жанры', sum_p]
genre_jp


fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(20,6))
fig.suptitle('Популярность жанров по регионам')
ax1.pie(genre_na['na_sales'], labels=genre_na['genre'],autopct='%1.0f%%')
ax1.set_title('na_sales')
ax2.pie(genre_eu['eu_sales'], labels=genre_eu['genre'],autopct='%1.0f%%')
ax2.set_title('eu_sales')
ax3.pie(genre_jp['jp_sales'], labels=genre_jp['genre'],autopct='%1.0f%%')
ax3.set_title('jp_sales')