这个笔记是in R:https://www.kaggle.com/umeshnarayanappa/explore-video-games-sales中的作品启发的。
笔记的目标是尽可能简单地实现在上面的R笔记本中创建的可视化,使用Python以及一些附加的情节,并添加了一些评论和解释,以帮助Seborn/Python初学者他们的数据可视化/自定义。我们通过玩不同的颜色来保持事物的趣味性。
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
Matplotlib is building the font cache using fc-list. This may take a moment.
使用熊猫在数据集中阅读。我们看到每一行条目对应于特定的游戏,数据包含游戏的名称、发布的年份以及一些分类特征,如平台、类型和发行者。最后,我们看到,游戏(行)条目还包括累计销售所取得的,按区域,按该特定的游戏。
df = pd.read_csv("/home/kesci/input/Datasets6073/vgsales.csv")
df.head()
Rank | Name | Platform | Year | Genre | Publisher | NA_Sales | EU_Sales | JP_Sales | Other_Sales | Global_Sales | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Wii Sports | Wii | 2006.0 | Sports | Nintendo | 41.49 | 29.02 | 3.77 | 8.46 | 82.74 |
1 | 2 | Super Mario Bros. | NES | 1985.0 | Platform | Nintendo | 29.08 | 3.58 | 6.81 | 0.77 | 40.24 |
2 | 3 | Mario Kart Wii | Wii | 2008.0 | Racing | Nintendo | 15.85 | 12.88 | 3.79 | 3.31 | 35.82 |
3 | 4 | Wii Sports Resort | Wii | 2009.0 | Sports | Nintendo | 15.75 | 11.01 | 3.28 | 2.96 | 33.00 |
4 | 5 | Pokemon Red/Pokemon Blue | GB | 1996.0 | Role-Playing | Nintendo | 11.27 | 8.89 | 10.22 | 1.00 | 31.37 |
检查最大年值,我们看到它是2020年,这是一个不可能的发布日期。
year_data = df['Year']
print("Max Year Value: ", year_data.max())
Max Year Value: 2020.0
通过错误年份查看条目的名称,我们可以在网上搜索游戏的发布日期,并将当前值替换为正确的发布日期。
max_entry = year_data.idxmax()
print(max_entry)
max_entry = df.iloc[max_entry]
pd.DataFrame(max_entry).T
5957
Rank | Name | Platform | Year | Genre | Publisher | NA_Sales | EU_Sales | JP_Sales | Other_Sales | Global_Sales | |
---|---|---|---|---|---|---|---|---|---|---|---|
5957 | 5959 | Imagine: Makeup Artist | DS | 2020 | Simulation | Ubisoft | 0.27 | 0 | 0 | 0.02 | 0.29 |
df['Year'] = df['Year'].replace(2020.0, 2009.0)
print("Max Year Value: ", year_data.max())
Max Year Value: 2017.0