<jupyter_start><jupyter_text>IntroductionThis dataset includes the list of games with sales recorded over 100,000 copies over different platforms and continents. It contains data for over 16,500 games from 1980 to 2016. This dataset was generated by scrape from  [VGChartz](https://www.vgchartz.com/).  QuestionTo narrow down to answering my main question, I have to explore what other factors in my dataset affects sale records of a game?- Factors such as:    1. Platform   2. Genre   3. Publisher   Find out which factors has done better overall in terms of sale records will help me answer the main questions:**Does publishing more games in any given genre leads to a high sale records?**    DatasetThis dataset has 11 unique columns.- Rank : Rank the games according to best overall sales records- Name : Name of the game- Platform : Name of the platform (i.e. PS2, PS3, PC,..) on which the game was released.- Year : The year in which the games was released- Genre : Genre of the game- Publisher : Publisher of the game- NA_Sales : Game's sale record in North America (in millions)- EU_Sales : Game's sale record in Europe (in millions)- JP_Sales : Game's sale record in Japan (in millions)- Other_Sales : Game's sale record in Other parts of the world (in millions)- Global_Sales : Game's sale record worldwide (in millions)<jupyter_code>## why are we using boxplot and countplot?
from Scripts import project_functions as pf
from Scripts import groupby_function as gf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# This will load data, remove the missing data and reset the index
df = pf.load_and_process("../data/raw/vgsales.csv")
# exporting the process data to a folder
df.to_csv("../data/processed/processed_vgsales.csv")
df<jupyter_output><empty_output><jupyter_text>Exploratory Data Analysis with observations **Which platform has the best total global sales?**<jupyter_code>col_list = ['Platform', 'Global_Sales']
df2 = (
    df.groupby(['Platform']).sum()
    .sort_values('Global_Sales', ascending = False)
    .reset_index(col_level = 1)
)
df2 = df2[col_list]
fig, ax = plt.subplots(figsize=(6,8))
sns.barplot(x='Global_Sales', y= 'Platform', data = df, estimator = np.sum)
plt.xlabel('Global_Sales (in millions)')
df2.head(11)<jupyter_output><empty_output><jupyter_text>Observations:- As we can see the PS2 has highest total game sales globally **Let's also see which platform has highest sale record in other part of the worlds?**<jupyter_code>df3 = df.groupby(['Platform']).sum()
columns = ['Rank', 'Year', 'Global_Sales']
df3.drop(columns, inplace = True, axis=1)
ax = df3.plot(kind = "barh", figsize=(15,20), width = 1, stacked = True, colormap = "tab20b")
ax.set_xlabel("Sales (in million)")
df3<jupyter_output><empty_output><jupyter_text>Observation:- Xbox has the highest total game sales in North America.- PS3 has the highest total game sales in Europe.- DS has the highest total game sales in Japan.- PS2 has the highest total game sales in other parts of the world. PC has been used worldwide but yet it is not the best perfroming platform. One of the reason I think is that PC games have been facing problem with pirating. Other platform like PS, GB, NES and Xbox it is tough to pirate games.Therefore, many games company sales record are not too high for PC. **Which publisher has good sales record throughout years globally? (As there many publisher! let's take top 15)**<jupyter_code>df3 = (df.groupby(['Publisher']).sum()
       .sort_values('Global_Sales', ascending = False)
       .reset_index(col_level = 1)
      )
top15 = df3.head(15)
fig, ax = plt.subplots(figsize=(10,20))
sns.barplot(x='Global_Sales', y='Publisher', data = top15)
plt.xlabel('Global_Sales (in millions)')
col = ['Publisher', 'Global_Sales']
top15[col]<jupyter_output><empty_output><jupyter_text>Observation:- As we can see that Nintendo has the highest global sales **Which Genre has been dominating the gaming industry globally?**<jupyter_code>fig, ax = plt.subplots(figsize=(10,20))
sns.barplot(x='Global_Sales', y='Genre', data = df, estimator = np.sum)
plt.xlabel('Global_Sales (in millions)')<jupyter_output><empty_output><jupyter_text>Observation:- Action has been taking over the gaming industry.  AnalysisAs of now we have seen which platform, publisher and Genre has the most game sales record. Now, we are going to focus on the main question Does pubishing more games in a dominating genre leads to higher sale of games?**Let's count the number of games published by each publisher**<jupyter_code>df5 = df.groupby(['Publisher']).count()
df5 = df5.sort_values('Global_Sales', ascending = False)
df5 = df5.rename(columns={"Rank": "No. of Games Published"})
col = ['No. of Games Published']
df5[col].head(15)
fig, ax = plt.subplots(figsize=(18,12))
sns.countplot(y='Publisher', data=df,order=df.Publisher.value_counts().iloc[:15].index)<jupyter_output><empty_output><jupyter_text>As we can see that Electronic Arts has the most number of game published. **Let's see which publisher has released the most amount of action games?**As we saw before, Action genre has the highest sales recorded. Therefore, we are trying to find if which publisher has published the most action genre games. Does that publisher has the highest sale records?<jupyter_code>col = ['Name', 'Publisher', 'Genre']
df6 = df[col]
df6 = df6[df6['Genre'].str.match('Action')]
df6 = ( df6.reset_index(col_level = 1)
       .drop(['index'], axis = 1)
      )
df6
fig, ax = plt.subplots(figsize=(18,15))
sns.countplot(y='Publisher', data=df6,order=df6.Publisher.value_counts().iloc[:15].index)<jupyter_output><empty_output><jupyter_text>As from the countplot above, we can observe that **Activision** has the most amount of action games published. However, they are third on the list of highest global sales.As of now, we know that in terms of sales record:- **PS2** is best platform - Best publisher is **Nintendo** - Best Genre is **Action** - Most game is published by **EA**- Most action games published by **Activision**One of the fun fact which will help us answer the main question is that almost all of the games made by Nintendo was on avaliable to only consoles by Nintendo themselves (i.e. Wii U, Wii, SNES, ...).Therefore, we lead to one more question:**How many Action based games were published by Activision on PS2?**As our main question is **Does publishing more games in a given genre leads to a high sale records?**As Activison as published the most action games, we will check what is the sale records of Activision publishing action based games on PS2 which is the best performing platform.<jupyter_code>df7 = df[df['Genre'].str.match('Action')]
df7 = df7[df7['Platform'].str.match('PS2')]
df7 = df7[df7['Publisher'].str.match('Activision')]
df7 = df7.groupby(['Platform']).sum()
col = ['Global_Sales']
df7[col]
df8 = df[df['Genre'].str.match('Action')]
df8 = df8[df8['Publisher'].str.match('Activision')]
df8 = df8[df8['Platform'].str.match('PS2')]
df8 = df8.groupby(['Platform']).count()
df8 = df8.rename(columns={"Name": "No. of Action Games"})
col = ['No. of Action Games']
df8[col]
df10 = df[df['Genre'].str.match('Action')]
df10 = df10[df10['Publisher'].str.match('Activision')]
df10 = df10.groupby(['Publisher']).sum()
col = ['Global_Sales']
df10[col].head(1)<jupyter_output><empty_output><jupyter_text>Activision has global sales of 141.82 (in millions) of action based games across all platforms.Activision has published 310 action games. Out of 310, 28 were released on PS2.<jupyter_code>(28/310)*100<jupyter_output><empty_output><jupyter_text>That's 9%. That 28 games on PS2 has made 22.34 (in million).<jupyter_code>(22.34/141.82)*100<jupyter_output><empty_output><jupyter_text>That's 15.75%.We have to find how many action games have Activision has published on other platforms and their global sale record and compare it with PS2 sales record.<jupyter_code>df11 = df[df['Genre'].str.match('Action')]
df11 = df11[df11['Publisher'].str.match('Activision')]
df11 = df11.groupby(['Platform']).count()
col = ['Rank']
df11 = df11[col]
df11 = df11.rename(columns={'Rank':'No. of the game published'})
df11
fig, ax = plt.subplots(figsize=(10,10))
line = df11.plot(kind = "bar", ax=ax, color=(0.2, 0.4, 0.6, 0.6))
df14 = df[df['Genre'].str.match('Action')]
df14 = df14[df14['Publisher'].str.match('Activision')]
df14 = df14.groupby(['Platform']).sum()
df14 = df14.rename(columns={'Global_Sales':'Global_Sales (in millions)'})
col = ['Global_Sales (in millions)']
df14 = df14[col]
df14
fig, ax = plt.subplots(figsize=(12,10))
line1 = df14.plot(kind = "bar",ax =ax,)
line = df11.plot(kind = "bar", ax=ax,color=(0.2, 0.4, 0.6, 0.6))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12393848978655038, 'fraction_numerical': 0.030525591002983705, 'mean_word_length': 5.474739970282318, 'pattern_counts': {'":': 2, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '498264', 'license': 'MIT', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2685, 'n_words': 995, 'path': 'analysis/.ipynb_checkpoints/milestone3-checkpoint.ipynb', 'repo_name': 'KaranGohil/Tableau_Seaborn_Project', 'size': '8714'}