Sign In

Course Project on EDA with Python

Analysis on Video Game Dataset

Exploratory analysis on Video Games Sales data

This Project is to perform the analysis on the Video Games Sales dataset. Here we use various libraries of Python for visualization of Data. The Dataset which is Used in Project is from Data World (👈 Click to Download)

The Libraries I used in Project are:

To install all required libraries, run the following Command:

pip install matplotlib seaborn numpy pandas plotly jovian --upgrade

Know About Data visualization:

The Data visualization is the graphic representation of data. It involves producing images that communicate relationships among the represented data to viewers. Visualizing data is an essential part of data analysis and machine learning. In this tutorial, we'll use Python libraries Matplotlib and Seaborn to learn and apply some popular data visualization techniques.

Their Following Tasks are Implemented in the Project:

Let's Get Dive into the Project !!

In [2]:
project_name = "analysis-on-videogames-sales-data"
In [3]:
!pip install jovian --upgrade -q
In [1]:
import jovian
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objs as go
import numpy as np
from plotly.offline import init_notebook_mode,iplot
import pandas as pd
%matplotlib inline
In [20]:
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abubakkarsid415/analysis-on-videogames-sales-data" on [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully!

Data Preparation and Cleaning

Here various modes of displaying dataset which is in CSV format. First step is to load the data using pandas read_csv function. the data is stored in mutidimensional table called as dataframe.

In [2]:
data = 'VideoGameSales.csv' #locate the CSV dataset in variable data
videogame_df = pd.read_csv(data) #read the data using pandas and store it in videogame_df variable
videogame_df #display the data (completely )

This Cell is to Explain the details of all Columns :

  • Ranking -- Game ranking based on the total sales (in millions)
  • Name -- Name of the Game
  • Platform -- Game Platforms like (PS4, PC, GB etc)
  • Year -- Year of game release
  • Genre -- Simply the game genre (sports, racing)
  • publisher -- name of the publisher
  • NA_Sales -- Sales in north america (in millions)
  • EU_sales -- Sales in Europe (in millions)
  • JAP_sales -- Sales in Japan (in millions)
  • IND_Sales -- Sales in India (in millions)
  • Global_Sales -- Total sales world wide ()
In [7]:

From above Dataframe, we conclude that :

  • 500 games are ranked based on their sales
  • Games released between 1980 to 2020
  • Mean/Average sales in all regions are very low compare to the Max ...
In [8]:
videogame_df.shape #To display the shape of the data (rows, columns)
(500, 11)
In [83]:
videogame_df.sort_values(by = ['Name']).head(30) #Display top 30 rows and Sort by 'Name' column
In [61]:
videogame_df.head(10) #To display top 10 rows from the dataset
In [55]:
videogame_df.tail(10) #Display 10 rows from bottom of dataframe
In [75]:
videogame_df[50:60] #Display the rows in range from 51 to 60

To Print all Columns names

In [94]:
#Method 1 to print all column names
for col in videogame_df.columns:

#Method 2 to print all col names
Rank Name Platform Year Genre Publisher NA_Sales EUR_Sales JAP_Sales IND_Sales Global_Sales
In [84]:
x = videogame_df['Name'].unique() #using numpy.ndarray to find all Names but only UNIQUE.
['Wii Sports' 'Super Mario Bros.' 'Mario Kart Wii' 'Wii Sports Resort' 'Pokemon Red/Pokemon Blue' 'Tetris' 'New Super Mario Bros.' 'Wii Play' 'New Super Mario Bros. Wii' 'Duck Hunt' 'Nintendogs' 'Mario Kart DS' 'Pokemon Gold/Pokemon Silver' 'Wii Fit' 'Wii Fit Plus' 'Kinect Adventures!' 'Grand Theft Auto V' 'Grand Theft Auto: San Andreas' 'Super Mario World' 'Brain Age: Train Your Brain in Minutes a Day' 'Pokemon Diamond/Pokemon Pearl' 'Super Mario Land' 'Super Mario Bros. 3' 'Grand Theft Auto: Vice City' 'Pokemon Ruby/Pokemon Sapphire' 'Pokemon Black/Pokemon White' 'Brain Age 2: More Training in Minutes a Day' 'Gran Turismo 3: A-Spec' 'Call of Duty: Modern Warfare 3' 'Pokémon Yellow: Special Pikachu Edition' 'Call of Duty: Black Ops' 'Pokemon X/Pokemon Y' 'Call of Duty: Black Ops 3' 'Call of Duty: Black Ops II' 'Call of Duty: Modern Warfare 2' 'Grand Theft Auto III' 'Super Smash Bros. Brawl' 'Animal Crossing: Wild World' 'Mario Kart 7' 'Halo 3' 'Pokemon HeartGold/Pokemon SoulSilver' 'Super Mario 64' 'Gran Turismo 4' 'Super Mario Galaxy' 'Pokemon Omega Ruby/Pokemon Alpha Sapphire' 'Super Mario Land 2: 6 Golden Coins' 'Grand Theft Auto IV' 'Gran Turismo' 'Super Mario 3D Land' 'Gran Turismo 5' 'Super Mario All-Stars' 'Pokemon FireRed/Pokemon LeafGreen' 'Just Dance 3' 'Call of Duty: Ghosts' 'Halo: Reach' 'Mario Kart 64' 'New Super Mario Bros. 2' 'Halo 4' 'Final Fantasy VII' 'Just Dance 2' 'Gran Turismo 2' 'Call of Duty 4: Modern Warfare' 'Donkey Kong Country' 'Minecraft' 'Animal Crossing: New Leaf' 'Mario Party DS' 'The Elder Scrolls V: Skyrim' 'Super Mario Kart' 'FIFA 16' 'Wii Party' 'Halo 2' 'Mario Party 8' 'Pokemon Black 2/Pokemon White 2' 'FIFA Soccer 13' 'The Sims 3' 'GoldenEye 007' 'Mario & Sonic at the Olympic Games' 'Final Fantasy X' 'Final Fantasy VIII' 'Pokémon Platinum Version' 'Pac-Man' 'Grand Theft Auto: Liberty City Stories' 'Super Mario Galaxy 2' 'Star Wars Battlefront (2015)' 'Call of Duty: Advanced Warfare' 'The Legend of Zelda: Ocarina of Time' 'Crash Bandicoot 2: Cortex Strikes Back' 'Super Mario Bros. 2' 'Super Smash Bros. for Wii U and 3DS' 'Call of Duty: World at War' 'Battlefield 3' 'The Legend of Zelda: Twilight Princess' 'Just Dance' 'Need for Speed Underground' 'Tekken 3' 'Crash Bandicoot 3: Warped' 'Super Smash Bros. Melee' 'Mario Kart 8' 'Fallout 4' 'Mario Kart: Double Dash!!' 'Just Dance 4' 'FIFA 14' 'Need for Speed Underground 2' 'Medal of Honor: Frontline' "Uncharted 3: Drake's Deception" 'Crash Bandicoot' 'Zumba Fitness' 'Gears of War 2' 'Uncharted 2: Among Thieves' 'FIFA 12' 'Big Brain Academy' 'Red Dead Redemption' 'FIFA 15' 'Donkey Kong Country Returns' 'The Legend of Zelda' "Assassin's Creed III" 'Halo: Combat Evolved' 'Pokémon Emerald Version' 'Kingdom Hearts' 'Pokémon Crystal Version' 'Halo 3: ODST' 'Super Mario Sunshine' 'Street Fighter II: The World Warrior' 'World of Warcraft' 'Driver' 'Kinect Sports' 'Gears of War 3' 'Gears of War' 'Metal Gear Solid 2: Sons of Liberty' 'Sonic the Hedgehog 2' 'Metal Gear Solid 4: Guns of the Patriots' 'Metal Gear Solid' 'The Last of Us' 'Final Fantasy XII' 'LittleBigPlanet' 'Dragon Quest IX: Sentinels of the Starry Skies' 'LEGO Star Wars: The Complete Saga' 'Resident Evil 2' 'Tekken 2' 'Cooking Mama' 'Destiny' "Assassin's Creed II" 'Super Smash Bros.' "Assassin's Creed" 'Batman: Arkham City' 'Forza Motorsport 3' 'Monster Hunter Freedom Unite' 'Super Mario Advance' 'Mario Kart: Super Circuit' 'Pokemon Stadium' 'Crash Bandicoot: The Wrath of Cortex' 'Final Fantasy XIII' 'Dr. Mario' 'Pokemon Pinball' 'Final Fantasy IX' 'Final Fantasy X-2' 'Donkey Kong 64' 'Professor Layton and the Curious Village' 'Tomb Raider II' 'Madden NFL 2004' 'Dragon Quest VIII: Journey of the Cursed King' 'Diablo III' 'New Super Mario Bros. U' 'Super Mario Land 3: Wario Land' 'The Legend of Zelda: Phantom Hourglass' "Donkey Kong Country 2: Diddy's Kong Quest" 'Tomodachi Life' 'Medal of Honor: Rising Sun' "Kirby's Dream Land" 'Fable III' 'Microsoft Flight Simulator' 'Guitar Hero II' 'Resident Evil 5' 'Grand Theft Auto: Vice City Stories' 'FIFA Soccer 11' 'Resident Evil' "Tony Hawk's Pro Skater" 'Warzone 2100' 'Spyro the Dragon' "Link's Crossbow Training" 'Guitar Hero III: Legends of Rock' 'Fallout 3' 'Pokemon Mystery Dungeon: Explorers of Time/Explorers of Darkness' "Uncharted: Drake's Fortune" 'Madden NFL 06' 'Diddy Kong Racing' 'Monster Hunter Freedom 3' 'God of War III' 'StarCraft II: Wings of Liberty' 'Crash Team Racing' 'FIFA 17' 'Driver 2' 'The Simpsons: Hit & Run' "Tony Hawk's Pro Skater 2" 'Animal Crossing: City Folk' 'The Lord of the Rings: The Two Towers' 'Forza Motorsport 4' 'Tomb Raider' 'The Legend of Zelda: A Link to the Past' 'The Legend of Zelda: The Wind Waker' 'Mario & Sonic at the Olympic Winter Games' "Luigi's Mansion: Dark Moon" 'Splatoon' 'Madden NFL 2005' 'Pitfall!' 'Madden NFL 07' 'Spider-Man: The Movie' 'Dragon Quest VII: Warriors of Eden' 'Uncharted: The Nathan Drake Collection' 'God of War' 'Nintendo Land' 'Michael Jackson: The Experience' "Tony Hawk's Pro Skater 3" 'Winning Eleven: Pro Evolution Soccer 2007' 'The Elder Scrolls IV: Oblivion' 'Zelda II: The Adventure of Link' 'Need for Speed: Most Wanted' 'Resistance: Fall of Man' 'Sonic the Hedgehog' 'Kingdom Hearts II' 'Asteroids' 'Fable II' 'Halo 5: Guardians' 'Super Mario 3D World' 'Batman: Arkham Asylum' "Assassin's Creed: Revelations" 'Namco Museum' 'Metal Gear Solid 3: Snake Eater' 'Daxter' 'Warcraft II: Tides of Darkness' 'FIFA Soccer 06' 'EyeToy Play' "Uncharted 4: A Thief's End" 'Gran Turismo 5 Prologue' 'Street Fighter IV' 'Teenage Mutant Ninja Turtles' 'Excitebike' 'Frogger' 'Madden NFL 2003' 'Watch Dogs' 'Half-Life' "Super Mario World 2: Yoshi's Island" 'FIFA Soccer 07' 'The Legend of Zelda: Skyward Sword' 'Street Fighter II Turbo' 'Carnival Games' 'World of Warcraft: The Burning Crusade' 'Fallout: New Vegas' 'God of War II' 'Forza Motorsport 2' 'World Soccer Winning Eleven 9' 'Namco Museum Vol.3' 'Tekken Tag Tournament' 'Far Cry 4' 'Star Fox 64' 'Golf' 'Professor Layton and the Diabolical Box' 'Left 4 Dead 2' 'Namco Museum: 50th Anniversary' 'EA Sports Active' "Assassin's Creed: Unity" 'Donkey Kong Land' "Tony Hawk's Underground" "Assassin's Creed IV: Black Flag" 'Monster Hunter 4 Ultimate' 'MotorStorm' 'Tekken 5' 'Dragon Warrior III' 'Sports Champions' 'NBA 2K16' 'World Soccer Winning Eleven 8 International' 'Flash Focus: Vision Training in Minutes a Day' 'Namco Museum Vol.1' "The Legend of Zelda: Link's Awakening" "Mario & Luigi: Bowser's Inside Story" 'Big Brain Academy: Wii Degree' 'Nintendogs + cats' 'Batman: Arkham Knight' 'Mario & Sonic at the London 2012 Olympic Games' 'LEGO Indiana Jones: The Original Adventures' "Resident Evil Director's Cut" 'Ratchet & Clank: Size Matters' 'Just Dance 2014' 'The Sims: Unleashed' 'Super Paper Mario' "Harry Potter and the Sorcerer's Stone" 'The Witcher 3: Wild Hunt' 'Resident Evil 3: Nemesis' 'Spyro: Year of the Dragon' 'FIFA Soccer 2005' 'Pokémon Trading Card Game' 'Battlefield 4' 'MySims' 'Friend Collection' "Tony Hawk's Pro Skater 4" 'Midnight Club 3: DUB Edition' 'Banjo-Kazooie' 'SOCOM: U.S. Navy SEALs' 'Guitar Hero: World Tour' 'Gran Turismo 6' 'Jak and Daxter: The Precursor Legacy' 'Pokemon Snap' 'FIFA Soccer 10' 'Pro Evolution Soccer 2008' 'Resident Evil 4' "Tom Clancy's The Division" 'Star Wars: Battlefront' 'Doom II: Hell on Earth' 'The Simpsons: Road Rage' 'Cooking Mama 2: Dinner With Friends' "Luigi's Mansion" 'Star Wars: Battlefront II' 'WWF SmackDown!' 'Croc: Legend of the Gobbos' 'The Getaway' 'Tomb Raider III: Adventures of Lara Croft' 'James Bond 007: Agent Under Fire' 'LEGO Star Wars: The Video Game' 'Rugrats in Paris: The Movie' "Spyro 2: Ripto's Rage!" 'Left 4 Dead' "Donkey Kong Country 3: Dixie Kong's Double Trouble!" "Assassin's Creed: Brotherhood" 'Kung Fu' 'Clubhouse Games' 'FIFA Soccer 2004' 'Battlefield: Bad Company 2' 'Guitar Hero: On Tour' 'Far Cry 3' 'Monster Hunter 4' 'Borderlands' 'Tekken 4' 'LittleBigPlanet 2' 'Grand Theft Auto 2' 'Final Fantasy III' 'Spider-Man 2' 'F-1 Race' 'FIFA Soccer 2003' 'Crash Bash' 'LEGO Batman: The Videogame' 'Metal Gear Solid V: The Phantom Pain' 'The Legend of Zelda: Spirit Tracks' 'WWF War Zone' "The Legend of Zelda: Majora's Mask" 'Professor Layton and the Unwound Future' 'Rugrats: Search For Reptar' 'English Training: Have Fun Improving Your Skills!' 'James Bond 007: Nightfire' 'Ratchet & Clank' 'Mario Party 9' 'Star Wars Episode III: Revenge of the Sith' 'Max Payne' 'The Lord of the Rings: The Return of the King' "Assassin's Creed Syndicate" 'True Crime: Streets of LA' 'Wii Music' 'Gran Turismo (PSP)' 'Monster Hunter X' 'Tekken' 'L.A. Noire' 'Madden NFL 16' 'Yokai Watch 2 Ganso/Honke' '007: Tomorrow Never Dies' 'Baseball' 'Killer Instinct' 'WWF SmackDown! 2: Know Your Role' 'Crisis Core: Final Fantasy VII' 'God of War: Chains of Olympus' 'Dragon Quest VI: Maboroshi no Daichi' 'Dance Central' 'Enter the Matrix' 'Super Mario Maker' 'Rhythm Heaven' 'Ace Combat 04: Shattered Skies' 'Club Penguin: Elite Penguin Force' 'Animal Crossing' 'Sonic Rush' 'Resident Evil 6' 'Halo: The Master Chief Collection' 'FIFA Soccer 08' 'Spider-Man' 'Need for Speed III: Hot Pursuit' 'Star Wars Episode I Racer' 'Personal Trainer: Cooking' 'Dragon Warrior IV' 'Heavy Rain' 'Mass Effect 2' 'Dragon Ball Z: Budokai' 'Madden NFL 2002' 'World Class Track Meet' 'Borderlands 2' 'The Legend of Zelda: A Link Between Worlds' 'Donkey Kong' 'The Sims: Vacation' 'Mass Effect 3' 'Kung Fu Panda' 'Epic Mickey' 'Saints Row 2' 'Rayman' 'Killzone 2' "Tom Clancy's Splinter Cell" "Mike Tyson's Punch-Out!!" 'WWE SmackDown! Shut Your Mouth' 'Gears of War: Ultimate Edition' 'NBA 2K13' 'Dragon Ball Z: Budokai Tenkaichi 3' 'wwe Smackdown vs. Raw 2006' 'Middle-Earth: Shadow of Mordor' 'Star Fox' 'The Sims: Livin Large' 'World Soccer Winning Eleven 6 International' 'Devil May Cry' 'Animal Crossing: Happy Home Designer' 'The Sims 4' 'Star Wars: The Old Republic' 'Sonic Heroes' 'Kirby Super Star Ultra' 'Hitman 2: Silent Assassin' 'Wave Race 64' 'SOCOM II: U.S. Navy SEALs' 'WWE SmackDown! vs. RAW 2006' 'inFAMOUS' 'Pac-Man Collection' 'Mass Effect' 'WarioWare: Smooth Moves' 'Cooking Mama: Cook Off' 'Titanfall' 'Sonic Mega Collection Plus' 'Sega Superstars Tennis' 'World Soccer Winning Eleven 7 International' 'Hot Shots Golf 3']
In [85]:
print('Total Games count(unique) :',len(x))
Total Games count(unique) : 431
In [122]:
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abubakkarsid415/analysis-on-videogames-sales-data" on [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully!

Exploratory Analysis and Visualization

Now, to use Matplotlib library to visualize the Dataset.

Few randomly created analysis on Video Game sales Dataset

In [9]:
vg_plot = videogame_df[0:25]
In [10]:
x = vg_plot['Rank']
y = vg_plot['Year']
plt.figure(figsize=(25,8), dpi= 80)
plt.plot(x,y, label = 'Year', color = 'green')
plt.title('Global Sales by Rank For 25 Rows')

Seaborn's kdeplot

Now we can also get a smooth estimate of the distribution using a kernel density estimation, which Seaborn does with sns.kdeplot

In [7]:
# Draw Plot
plt.figure(figsize=(25,8), dpi= 80)
sns.kdeplot(videogame_df.Global_Sales, shade=True, label = 'Global Sales', color="r", alpha=.7)

# Decoration
plt.title('Overall Global Sales Distribution', fontsize=16)
In [11]:
total = vg_plot['Global_Sales']
NA = vg_plot['NA_Sales']
EUR = vg_plot['EUR_Sales']
JAP = vg_plot['JAP_Sales']
IND = vg_plot['IND_Sales']
In [166]:
plt.figure(figsize=(25,8), dpi= 80)
plt.title('Comparision With all Countries with Global Sales')

plt.plot(total, label = 'Global')
plt.plot(NA, label = 'AMERICA')
plt.plot(EUR, label = 'EUROPE')
plt.plot(JAP, label = 'JAPAN')
plt.plot(IND, label = 'INDIA')
plt.legend(bbox_to_anchor =(1.0, 1.025), ncol = 2)
<matplotlib.legend.Legend at 0x2152a65b9a0>
In [14]:
kwargs = dict(histtype='barstacked', alpha=0.3, bins=40)
plt.hist(total, **kwargs)
plt.hist(NA, **kwargs)
plt.hist(EUR, **kwargs)
plt.hist(JAP, **kwargs)
plt.hist(IND, **kwargs)
plt.xlabel('Global Sales')
plt.title('Stepfield type of Comparision of Global with all Countries')
Text(0.5, 1.0, 'Stepfield type of Comparision of Global with all Countries')
In [183]:
x = vg_plot['Year']
y = vg_plot['Global_Sales']
plt.title('Global sales occur (in Millions)')
plt.hist2d(x, y, bins=22, cmap='hot_r')
cb = plt.colorbar()
cb.set_label('counts in bin')

Exploring Seaborn Plots

The main idea of Seaborn is that it provides high-level commands to create a variety of plot types useful for statistical data exploration, and even some statistical model fitting. Let's take a look with our dataset 'videogame_df' and plot the types available in Seaborn.

Maximum games sold using Countplot method

In [76]:
plt.title('Maximum Games sold on basis of Year')

Top 10 Platforms, Genres, Publishers with Histogram plotting

In [152]:
#top platforms (name of the platform,total number of games developed for that platform)
topPlatforms_index = videogame_df.Platform.value_counts().head(10).index
topPlatforms_values = videogame_df.Platform.value_counts().head(10).values

#top genres (name of the genre,total number of games developed in that genre)
topGenres_index = videogame_df.Genre.value_counts().head(10).index
topGenres_values = videogame_df.Genre.value_counts().head(10).values

#top game developers/publishers (name of the publisher,total number of games published by that publisher)
topPublisher_index = videogame_df.Publisher.value_counts().head(10).index
topPublisher_values = videogame_df.Publisher.value_counts().head(10).values

fig, (ax1,ax2) = plt.subplots(1,2,figsize=(25,8), facecolor='white')

##top platforms used for games
ax1.vlines(x=topPlatforms_index, ymin=0, ymax=topPlatforms_values, color='#AD0605', linewidth=30)
ax1.set_title('Top 10 Platforms',fontsize=16)

#top genres of Games accordingly
ax2.vlines(x=topGenres_index, ymin=0, ymax=topGenres_values, color='#AB0DD5', linewidth=30)
ax2.set_title('Top 10 Genres',fontsize=16)

fig, ax = plt.subplots(figsize=(25,8), facecolor='white')

#top publishers of the games
ax.vlines(x=topPublisher_index, ymin=0, ymax=topPublisher_values, linewidth=65, color='#969F79')
ax.set_title('Top 10 Publishers',fontsize=16)

Text(0.5, 1.0, 'Top 10 Publishers')

Conclution for above Bar Graph are :

  • DS and PS2 are the most popular platforms in comparison to others platform.
  • Action is the most popular genre and the second most is the sports
  • Electronic Arts has published 1300+ products

Corellating the Games Sales among Countries and Global with Seaborn

Visualizing the multidimensional relationships among the samples is as easy as calling sns.pairplot:

In [228]:
# Corellating among all Continents/Countries using Seaborn to perform pairplot and to plot the graph with matplotlib:


Conclution Upon performing the correlation among various countries :

  • North America is the major market as the Global sales are highly correlated with it.
  • Europe is also an important region.
  • One intresting thing is Japanies sales are not correlated with any region's sales,We can assume that JAPANIES people have different taste, when it's about games.


In [36]:
top15 = videogame_df[0:15]
In [167]:
plt.figure(figsize = (18,8))
plt.barh(top15["Name"],top15["IND_Sales"], label = 'Top Games')
plt.title("Top 15 games sold in India",fontdict = {"fontsize":20})
plt.savefig("Top 15 games soldm in India.jpg",dpi = 300) #And to save it as an Jpeg image in the Directory


In [50]:
Publisher = list(videogame_df.Publisher.unique())
global_sale_of_every_Publisher = pd.Series(dtype = float)
for pub in Publisher :
    data = videogame_df.loc[videogame_df.Publisher == pub]
    global_sale = sum(data.Global_Sales)
    global_sale_of_every_Publisher[pub] = global_sale
In [52]:
top_10 = global_sale_of_every_Publisher[:10]
In [69]:
plt.figure(figsize = (10.5,9))
plt.pie(top_10,labels = top_10.index,autopct = "%.2f%%",textprops = {"fontsize":13},labeldistance = 1.05)
plt.legend(loc = 4,fontsize  = 12, bbox_to_anchor =(1.75, 0.82), ncol = 2)
plt.title("Top 10 Publisher of Games",fontdict = {"fontsize":25,"fontweight":100})
plt.savefig("Top 10 Publisher of Games",dpi = 200)

Percentage of Each Genre of Games

In [14]:
Genre = videogame_df.Genre
Genre = Genre.value_counts()
In [15]:
plt.figure(figsize = (8,8))
labels = Genre.index
colors = ["#eeff00","#51ff00","#00ffdd","#ff9d00","#0033ff","#ff0800","#f700ff","#850012","#c7714a","#04615b","#ab8d5e","#00004a"]
plt.pie(Genre,labels = labels,colors = colors,autopct = "%.2f%%") 
plt.title("Percentage of Top Genres of Games",fontdict = {"fontsize":17})
plt.savefig("Top Genres Chart",dpi = 200)

Best Selling Games in Countries

In [234]:
df1 = pd.DataFrame(videogame_df.groupby('Name')['NA_Sales'].sum())
df1.sort_values(by=['NA_Sales'], inplace=True)
df1 = df1.tail(5)
df1.plot.pie(y='NA_Sales', autopct='%1.1f%%', figsize=(6, 6))
plt.title("Best selling games in North America")

df1 = pd.DataFrame(videogame_df.groupby('Name')['EUR_Sales'].sum())
df1.sort_values(by=['EUR_Sales'], inplace=True)
df1 = df1.tail(5)
df1.plot.pie(y='EUR_Sales', autopct='%1.1f%%', figsize=(6, 6))
plt.title("Best selling games in Europe")

df1 = pd.DataFrame(videogame_df.groupby('Name')['IND_Sales'].sum())
df1.sort_values(by=['IND_Sales'], inplace=True)
df1 = df1.tail(5)
df1.plot.pie(y='IND_Sales', autopct='%1.1f%%', figsize=(6, 6))
plt.title("Best selling games in INDIA")

df1 = pd.DataFrame(videogame_df.groupby('Name')['JAP_Sales'].sum())
df1.sort_values(by=['JAP_Sales'], inplace=True)
df1 = df1.tail(5)
df1.plot.pie(y='JAP_Sales', autopct='%1.1f%%', figsize=(6, 6))
plt.title("Best selling games in Japan");

Video Game Sale Based on Genre (Global vs. INDIA)

In [18]:
df_genre = videogame_df.groupby('Genre')
def genreBased(region):
    xrange = np.arange(1,len(df_genre.sum())+1)
    fig,ax= plt.subplots(ncols=2,figsize=(18,6))
    df_to_plot = df_genre.sum().sort_values(by=region,ascending =False)[::-1]
    ax[1].tick_params(axis='both', which='major', labelsize=13)
    ax[1].set_xlabel('Total Sales(in millions)', fontsize=15,labelpad=21)
    for x,y in zip(np.arange(len(df_genre.sum())+1),df_genre.sum().sort_values(by=region,ascending =False)[::-1][region]):
        label = "{:}".format(y)
        labelr = round(y,2)
        plt.annotate(labelr, # this is the text
                     (y,x), # this is the point to label
                      textcoords="offset points",# how to position the text
                     xytext=(6,0), # distance from text to points (x,y)
    #donut chart
    theme = plt.get_cmap('Blues')
    ax[0].set_prop_cycle("color", [theme(1. * i / len(df_to_plot))for i in range(len(df_to_plot))])    
    wedges, texts,_ = ax[0].pie(df_to_plot[region], wedgeprops=dict(width=0.45), startangle=-45,labels=df_to_plot.index,
                      autopct="%.1f%%",textprops={'fontsize': 13,})

In [19]:
genreBased('Global_Sales') #ABOVE
genreBased('IND_Sales') #BELOW