第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

堆積條形圖,按游戲類型堆積

堆積條形圖,按游戲類型堆積

ABOUTYOU 2023-08-22 10:38:07
我有一個(gè)視頻游戲銷售數(shù)據(jù),我能夠按年份繪制視頻游戲銷售圖表,但是我想做一個(gè)堆積圖表,這意味著人們會知道在某一年動(dòng)作游戲銷售多少射擊游戲銷售策略游戲銷售等您的幫助將不勝感激按年份劃分的銷售額樣本數(shù)據(jù):,Year,Genre,Global_Sales0,2006.0,Sports,82.741,1985.0,Platform,40.242,2008.0,Racing,35.823,2009.0,Sports,33.04,1996.0,Role-Playing,31.375,1989.0,Puzzle,30.266,2006.0,Platform,30.017,2006.0,Misc,29.028,2009.0,Platform,28.629,1984.0,Shooter,28.3110,2005.0,Simulation,24.7611,2005.0,Racing,23.4212,1999.0,Role-Playing,23.113,2007.0,Sports,22.7214,2009.0,Sports,22.015,2010.0,Misc,21.8216,2013.0,Action,21.417,2004.0,Action,20.8118,1990.0,Platform,20.6119,2005.0,Misc,20.22import matplotlib.pyplot as pltimport pandas as pdimport numpy as npdf = pd.read_csv('vgsales.csv')df.dropna(subset = ['Year'], inplace=True)df['Year']=df['Year'].astype(int)df['Year']= df['Year'].astype(str)df.set_index(['Year'],inplace=True)df = df.groupby(['Year']).agg({'Global_Sales':np.sum}) #gives sales for each year# df= df.groupby(['Year','Genre']).agg({'Global_Sales':np.sum}) # gives sales by each genre?# gf = df.groupby('Genre')# df.reset_index(inplace=True)# df.sort_values(df.index, inplace=True)# plt.bar(df.index.get_level_values(0), df['Global_Sales'])lab = df.index.get_level_values(0)y = df['Global_Sales']x = np.arange(len(lab))plt.figure(figsize=(10,10))plt.bar(x,y)plt.title('Video Game Sales in Past Years', fontsize=20)plt.xlabel('Years')plt.ylabel('Sales (Millions)')plt.xticks(x, lab, rotation = 'vertical')plt.show()
查看完整描述

1 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

使用Kaggle 的數(shù)據(jù):視頻游戲銷售

嘗試:

df = pd.read_csv('data/kaggle/video_game_sales/vgsales.csv')


dfg = df.groupby(['Year','Genre']).agg({'Global_Sales':np.sum})


ax = dfg['Global_Sales'].unstack().plot.bar(stacked=True, figsize=(10,10))

plt.legend(title='Game Genre', bbox_to_anchor=(1.05, 1), loc='upper left')

ax.set_title('Global Sales')

ax.set_ylabel('Sales (Millions)')

ax.set_xlabel('Years')

https://img4.sycdn.imooc.com/64e41fc20001017e07500634.jpg

查看完整回答
反對 回復(fù) 2023-08-22
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號