目錄
資料概述
指標體系
核心指標:營收
指標拆解:從游戲題材、出版商、發行年份、地區對營收方面的表現進行比較
小結
匯入庫
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
資料摸底
#讀取檔案
df=pd.DataFrame(pd.read_csv('vgsales.csv'))
#初步了解
print(df.info())
print(df.describe())
#檢查空值
print(df.isnull().any())
print(df.isnull().sum())
指標計算
1.不同體裁的游戲在營收方面的表現
(縱向對比,即比較不同的平臺在同一方面的營收情況)
genre_sale=df.groupby('Genre').agg(NAsales=('NA_Sales','sum'),EUsales=('EU_Sales','sum'),
JPsales=('JP_Sales','sum'),Othsales=('Other_Sales','sum'),
Glosales=('Global_Sales','sum')).sort_values(by='Genre')
1.1全球銷量排名
genre_sale['rank']=genre_sale['Glosales'].rank(method='min',ascending=False)
1.2全球銷量排名前三的體裁
print(genre_sale.query('rank<=3'))
1.3繪圖
1.3.1折線圖
plt.figure()
x=genre_sale.index
y=genre_sale['Glosales']
z=genre_sale['Othsales']
plt.xticks(rotation=30)
plt.plot(x, y,label='glo')
plt.plot(x,z,label='oth')
plt.legend()
for a,b in zip(x,y):
plt.text(a,b+10,'%.2f' % b,ha='center')
for a,b in zip(x,z):
plt.text(a,b+10,'%.2f' % b,ha='center')
plt.figure()
c=genre_sale['NAsales']
d=genre_sale['EUsales']
e=genre_sale['JPsales']
plt.plot(x,c,label='NA')
plt.plot(x,d,label='EU')
plt.plot(x,e,label='JP')
plt.legend()
plt.xticks(rotation=30)
1.3.2條形圖(結構條形圖)
plt.figure()
plt.bar(x,c,label='NA',color='pink')
plt.bar(x,d,label='EU',color='purple')
plt.bar(x,e,label='JP',color='lightblue')
plt.legend()
plt.xticks(rotation=30)
for a,b in zip(x,c):
plt.text(a,b,'%.2f' % b,ha='center')
1.4評級
def sale_label(x):
if x>np.mean(genre_sale['Glosales']):
return 'high'
else:
return 'low'
genre_sale['label']=genre_sale['Glosales'].apply(lambda x:sale_label(x))

在全球營收方面,動作類、體育類、射擊類游戲營收最高,考慮與游戲市場的受眾有關,游戲市場中男性用戶占比較大,其游戲偏好偏向上述題材,
在其他營收方面,各題材型別差異相對較小,與其他營收在總營收中占比較小有關,動作類、體育類的營收優勢較為明顯,同樣反映出用戶的題材偏好,

各題材在北美與歐洲的營收曲線較為一致, 仍是動作、射擊、體育類題材占優勢,用戶偏好明顯,
但在日本市場,角色扮演型別的游戲營收最高且營收優勢明顯,其他題材的游戲營收差別較小,考慮與日本普遍性較高的動漫文化有關,日本獨特的文化環境塑造出日本市場獨特的游戲偏好,因此針對日本的游戲市場策略需要與其他國家有所區分,推測以動漫為出發點衍生出的游戲在日本會具有較多的受眾,

2.不同平臺在營收方面的表現
plat_sale=df.groupby('Platform').agg(NAsales=('NA_Sales','sum'),EUsales=('EU_Sales','sum'),
JPsales=('JP_Sales','sum'),Othsales=('Other_Sales','sum'),
Glosales=('Global_Sales','sum'))
2.1縱向對比,即比較不同的平臺在同一方面的營收情況
plat_sale['rank']=plat_sale['Glosales'].rank(method='min',ascending=False)
plt.figure()
for i in range(plat_sale.shape[1]):
x1=plat_sale.index
y1=plat_sale.iloc[:,i]
plt.bar(x1,y1,color='orange')
plt.xticks(rotation=90)
plt.ylabel(plat_sale.columns[i])
plt.show()
2.2橫向對比,即比較同一平臺在不同方面的營收情況
for i in range(len(plat_sale)):
f1=pd.DataFrame(plat_sale.iloc[i,:])
plt.plot(f1,color='orange')
plt.ylabel(f1.columns)
for n,g in zip(f1.index,f1.iloc[:,0]):
plt.text(n,g,'%.2f' % g,ha='center')
plt.show()
縱向




不同平臺在不同地區的營收表現不同,峰值主要集中在PS、DS、Wii
DS在日本市場表現最好,但其歐美市場仍然需要開拓
在其他方面的營收,各個平臺的表現差異最大
PS在歐洲營收、全球營收、總營收表現最好
橫向


3.不同出版商在營收方面的表現
3.1分組計算
pub_sale=df.groupby('Publisher').agg(NAsales=('NA_Sales','sum'),EUsales=('EU_Sales','sum'),
JPsales=('JP_Sales','sum'),Othsales=('Other_Sales','sum'),
Glosales=('Global_Sales','sum'))
3.2排名
pub_sale['rank']=pub_sale['Glosales'].rank(method='min',ascending=False)
pub_sale_20=pub_sale.query('rank<=20')
3.3畫圖
plt.figure()
x2=pub_sale_20.index
y2=pub_sale_20['Glosales']
plt.plot(x2,y2,color='orange')
plt.xticks(rotation=90)
for a,b in zip(x2,y2):
plt.text(a,b+10,'%.2f' % b,ha='center')

不同出版商在總營收方面的表現差異較大,存在一定程度上的壟斷,
對于營收較低的出版商,可根據用戶的游戲偏好推出相應型別的游戲,開拓市場,
4.不同年份在營收方面的的表現
4.1給年份分組
def year_group(x):
if x<=1990:
return '1980-1990'
elif x<=2000:
return '1991-2000'
elif x<=2010:
return '2001-2010'
else:
return '2011-2020'
list1=[]
for i in df['Year']:
a=year_group(i)
list1.append(a)
df['year_group']=list1
#另一種寫法
#df['year_group']=df['Year'].apply(lambda x:year_group(x))
4.2分組計算
year_sale=df.groupby('year_group').agg(NAsales=('NA_Sales','sum'),EUsales=('EU_Sales','sum'),
JPsales=('JP_Sales','sum'),Othsales=('Other_Sales','sum'),
Glosales=('Global_Sales','sum'))
4.3畫圖
plt.figure()
for i in range(year_sale.shape[1]):
x2=year_sale.index
y2=year_sale.iloc[:,i]
plt.plot(x2,y2,label=year_sale.columns[i])
for a,b in zip(x2,y2):
plt.text(a,b,'%.2f' % b,ha='center')
plt.legend()

各地區的營收趨勢較為一致,2001-2010年,游戲行業發展迅速,各地區營收迅速上升,但在2010年之后,各地區游戲行業營收水平有所下降,推測可能一方面由于全球化其他行業的發展,游戲行業受到沖擊,另一方面與各地區推出的游戲、經濟政策有關,
5.不同游戲在營收方面的表現
5.1分組計算
game_sale=df.groupby('Name').agg(NAsales=('NA_Sales','sum'),EUsales=('EU_Sales','sum'),
JPsales=('JP_Sales','sum'),Othsales=('Other_Sales','sum'),
Glosales=('Global_Sales','sum'))
5.2游戲在不同國家營收的排名
for i in range(game_sale.shape[1]):
coname=game_sale.columns
game_sale[coname[i]+'_rate']=game_sale.iloc[:,i].rank(method='min',ascending=False)
5.3取出不同國家營收排名前十的游戲
for i in range(5,10):
outn=game_sale[game_sale.iloc[:,i]<=10].iloc[:,i]
print(outn)
6.不同體裁在不同渠道的總營收以及占比
6.1營收
6.1.1資料透視表的寫法
gen_pla=pd.pivot_table(df,values='Global_Sales',index='Genre',columns='Platform',aggfunc=np.sum).fillna(0)
6.1.2分組求和寫法
gen_pla_rate=df.groupby(['Genre','Platform']).sum()['Global_Sales'].unstack().fillna(0)
gen_pla_rate['total']=np.sum(gen_pla_rate,axis=1)
6.2占比
new=pd.DataFrame(index=gen_pla_rate.index,columns=gen_pla_rate.columns)
for i in gen_pla_rate.columns:
new[i]=round(gen_pla_rate[i]/gen_pla_rate['total'],2)
6.3畫圖(橫向畫圖,列名是橫坐標)
plt.figure()
for i in range(0,8):
table1=pd.DataFrame(gen_pla_rate.iloc[i,:])
plt.plot(table1)
plt.xticks(rotation=90)
for n,g in zip(table1.index,table1.iloc[:,0]):
plt.text(n,g,'%.2f' % g,ha='center')
plt.show()
#如果不寫plt.show,會都畫在一張圖里
7.不同體裁在不同年份的總營收表現
7.1分組計算
gen_year_rate=df.groupby(['Genre','year_group']).sum()['Global_Sales'].unstack().fillna(0)
gen_year_rate['total']=np.sum(gen_year_rate,axis=1)
7.2不同年份營收在體裁總營收的占比
for i in range(0,4):
colname=gen_year_rate.columns
gen_year_rate[colname[i]+'rate']=round(gen_year_rate.iloc[:,i]/gen_year_rate['total'],2)
7.3畫圖
#畫圖(縱向畫圖,行名是橫坐標)
for i in range(0,5):
colabel=gen_year_rate.columns
x3=gen_year_rate.index
y3=gen_year_rate.iloc[:,i]
plt.plot(x3,y3,label=colabel[i])
plt.legend()
plt.xticks(rotation=75)

不同年份,各個游戲題材的全球營收情況有一定程度的差異 ,例如動作類游戲在1980-2000年營收表現并不優秀,但自2001年開始,其全球營收最高,即該題材游戲自2000年熱度開始上升,射擊類游戲同樣如此,運動類游戲、角色扮演類游戲從1991年開始有所發展,platform型別的游戲在1980-2000年營收表現較好,自2001年開始衰落,推測可能是受到其他幾種游戲型別的沖擊,
8.不同平臺在不同年份的總營收表現
8.1分組計算
pla_year_rate=df.groupby(['Platform','year_group']).sum()['Global_Sales'].unstack().fillna(0)
pla_year_rate['total']=np.sum(pla_year_rate,axis=1)
8.2計算占比
for i in range(0,4):
colname=pla_year_rate.columns
pla_year_rate[colname[i]+'_rate']=round(pla_year_rate.iloc[:,i]/pla_year_rate['total'],2)
8.3判斷占比大小
def high_low(x):
if x>=0.5:
return 'high'
elif x>=0.3:
return 'middle'
else:
return 'low'
for i in range(5,9):
colname=pla_year_rate.columns
pla_year_rate[colname[i]+'_value']=pla_year_rate.iloc[:,i].apply(lambda x:high_low(x))
8.3依次按照每一年的占比大小分組,并計數
for i in range(9,13):
a=pd.DataFrame(pla_year_rate.groupby(pla_year_rate.iloc[:,i]).count()['1980-1990'])
print(a)
9.不同出版尚在不同年份的總營收表現
pub_year_rate=df.groupby(['Publisher','year_group']).sum()['Global_Sales'].unstack().fillna(0)
pub_year_rate['total']=np.sum(pub_year_rate,axis=1)
9.1占比
for i in range(0,4):
colname=pub_year_rate.columns
pub_year_rate[colname[i]+'_rate']=round(pub_year_rate.iloc[:,i]/pub_year_rate['total'],2)
9.2判斷占比的大小
for i in range(5,9):
colname=pub_year_rate.columns
pub_year_rate[colname[i]+'_value']=pub_year_rate.iloc[:,i].apply(lambda x:high_low(x))
9.3一次按照每一年的占比大小分組,并計數
for i in range(9,13):
a=pd.DataFrame(pub_year_rate.groupby(pub_year_rate.iloc[:,i]).count()['1980-1990'])
print(a)
小結
總的來說,用戶的游戲題材偏好較為明顯,總體上體育、動作、射擊型別的游戲營收較多,但同時,不同地區的題材偏好也有所區別,例如日本市場更偏向角色扮演類的游戲,這與其地域文化存在聯系,因此,針對不同的地區,應制定不同的游戲策略,
此外,就出版商而言,游戲行業存在一定程度的壟斷,即整體上不同出版商差異較大,營收較高的出版商數量較少,
最后,在趨勢上,不同題材的游戲型別其營收狀況也會隨時間發生改變,目前受眾較多的游戲型別大多是從2000年后開始流行,而在1980年-2000年流行的游戲題材在2000年之后其熱度開始下降,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/338198.html
標籤:其他
