{"id":19467691,"url":"https://github.com/fanisgl/video-games-sales-data","last_synced_at":"2026-04-29T23:03:53.509Z","repository":{"id":254870077,"uuid":"847804441","full_name":"FanisGl/Video-games-sales-data","owner":"FanisGl","description":"Data Analysis of Sales Dataset using Python.","archived":false,"fork":false,"pushed_at":"2024-08-29T14:59:48.000Z","size":1174,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T04:35:16.577Z","etag":null,"topics":["data-analysis","data-science","data-visualization","dataset","jupyter-notebooks","matplotlib","numpy","pandas","poisson-distribution","python","python3","sales","statistics"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FanisGl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-26T15:21:40.000Z","updated_at":"2024-08-29T14:59:51.000Z","dependencies_parsed_at":"2024-08-29T16:28:09.660Z","dependency_job_id":"08f5f156-6e68-46ad-b310-25e6c710a043","html_url":"https://github.com/FanisGl/Video-games-sales-data","commit_stats":null,"previous_names":["fanisgl/video-games-sales-data"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FanisGl%2FVideo-games-sales-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FanisGl%2FVideo-games-sales-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FanisGl%2FVideo-games-sales-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FanisGl%2FVideo-games-sales-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FanisGl","download_url":"https://codeload.github.com/FanisGl/Video-games-sales-data/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240681009,"owners_count":19840315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analysis","data-science","data-visualization","dataset","jupyter-notebooks","matplotlib","numpy","pandas","poisson-distribution","python","python3","sales","statistics"],"created_at":"2024-11-10T18:36:30.491Z","updated_at":"2026-04-29T23:03:53.463Z","avatar_url":"https://github.com/FanisGl.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Video-games Sales Data Analysis\r\n\u003e Tags: [Data Analytics], [Statistics]\r\n\u003e\r\n\u003e Technical Skills: [Python], [Jupyter Notebook], [Pandas], [Numpy], [Matplotlib]\r\n\u003e\r\n\u003e Theoretical Frameworks: [Poisson Distribution]\r\n\r\n\u003e[!NOTE]\r\n\u003e \u003csub\u003e An exercise done with the assistance provided from the Workearly team when I was doing my bootcamp back in 2023. They are specialised educational professionals that offer extraordinary upskilling bootcamps and more. \u003c/sub\u003e\r\n\u003e\r\n\u003e \u003csub\u003e I started my journey of upskilling last February with them, and thanks to the learning structure they offer, they had helped me become adept in 6 different tools and use them in a professional environment in only 10 months, including how to utilise Python in Data Science as seen below. \u003c/sub\u003e\r\n\u003e\r\n\u003e \u003csub\u003e Make sure you check them out if you are interested in any sort of upskilling for you or your team: https://www.workearly.gr/ \u003c/sub\u003e\r\n\u003e\r\n\u003e \u003csub\u003e The dataset was distributed by the user GregorySmith(gregorut): https://www.kaggle.com/datasets/gregorut/videogamesales \u003c/sub\u003e\r\n\r\n\r\nA simplistic execution of EDA (Exploratory Data Analysis), to answer 7 questions, and perform a poisson distribution to model the data.\r\n\r\n\r\n```python\r\nimport pandas as pd\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport math\r\n```\r\n\r\n\r\n```python\r\n# Calling the CSV\r\ndf = pd.read_csv(r'B:\\Python Environments\\Video Game Data Analysis\\Raw Data\\vgsales.csv')\r\n#r'' because I just want to copy/paste the path without changing all the \\ to / or to \\\\\r\n```\r\n\r\n## Cleaning the Dataset\r\nDropping N/A and nulls.\r\n\r\n\r\n```python\r\ndf.dropna(inplace=True)\r\n```\r\n\r\n## Exploring the CSV's features\r\n\r\n\r\n```python\r\ndf.head()\r\n```\r\n\r\n\r\n\r\n\r\n\u003cdiv\u003e\r\n\u003c/style\u003e\r\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\r\n  \u003cthead\u003e\r\n    \u003ctr style=\"text-align: right;\"\u003e\r\n      \u003cth\u003e\u003c/th\u003e\r\n      \u003cth\u003eRank\u003c/th\u003e\r\n      \u003cth\u003eName\u003c/th\u003e\r\n      \u003cth\u003ePlatform\u003c/th\u003e\r\n      \u003cth\u003eYear\u003c/th\u003e\r\n      \u003cth\u003eGenre\u003c/th\u003e\r\n      \u003cth\u003ePublisher\u003c/th\u003e\r\n      \u003cth\u003eNA_Sales\u003c/th\u003e\r\n      \u003cth\u003eEU_Sales\u003c/th\u003e\r\n      \u003cth\u003eJP_Sales\u003c/th\u003e\r\n      \u003cth\u003eOther_Sales\u003c/th\u003e\r\n      \u003cth\u003eGlobal_Sales\u003c/th\u003e\r\n    \u003c/tr\u003e\r\n  \u003c/thead\u003e\r\n  \u003ctbody\u003e\r\n    \u003ctr\u003e\r\n      \u003cth\u003e0\u003c/th\u003e\r\n      \u003ctd\u003e1\u003c/td\u003e\r\n      \u003ctd\u003eWii Sports\u003c/td\u003e\r\n      \u003ctd\u003eWii\u003c/td\u003e\r\n      \u003ctd\u003e2006.0\u003c/td\u003e\r\n      \u003ctd\u003eSports\u003c/td\u003e\r\n      \u003ctd\u003eNintendo\u003c/td\u003e\r\n      \u003ctd\u003e41.49\u003c/td\u003e\r\n      \u003ctd\u003e29.02\u003c/td\u003e\r\n      \u003ctd\u003e3.77\u003c/td\u003e\r\n      \u003ctd\u003e8.46\u003c/td\u003e\r\n      \u003ctd\u003e82.74\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n      \u003cth\u003e1\u003c/th\u003e\r\n      \u003ctd\u003e2\u003c/td\u003e\r\n      \u003ctd\u003eSuper Mario Bros.\u003c/td\u003e\r\n      \u003ctd\u003eNES\u003c/td\u003e\r\n      \u003ctd\u003e1985.0\u003c/td\u003e\r\n      \u003ctd\u003ePlatform\u003c/td\u003e\r\n      \u003ctd\u003eNintendo\u003c/td\u003e\r\n      \u003ctd\u003e29.08\u003c/td\u003e\r\n      \u003ctd\u003e3.58\u003c/td\u003e\r\n      \u003ctd\u003e6.81\u003c/td\u003e\r\n      \u003ctd\u003e0.77\u003c/td\u003e\r\n      \u003ctd\u003e40.24\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n      \u003cth\u003e2\u003c/th\u003e\r\n      \u003ctd\u003e3\u003c/td\u003e\r\n      \u003ctd\u003eMario Kart Wii\u003c/td\u003e\r\n      \u003ctd\u003eWii\u003c/td\u003e\r\n      \u003ctd\u003e2008.0\u003c/td\u003e\r\n      \u003ctd\u003eRacing\u003c/td\u003e\r\n      \u003ctd\u003eNintendo\u003c/td\u003e\r\n      \u003ctd\u003e15.85\u003c/td\u003e\r\n      \u003ctd\u003e12.88\u003c/td\u003e\r\n      \u003ctd\u003e3.79\u003c/td\u003e\r\n      \u003ctd\u003e3.31\u003c/td\u003e\r\n      \u003ctd\u003e35.82\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n      \u003cth\u003e3\u003c/th\u003e\r\n      \u003ctd\u003e4\u003c/td\u003e\r\n      \u003ctd\u003eWii Sports Resort\u003c/td\u003e\r\n      \u003ctd\u003eWii\u003c/td\u003e\r\n      \u003ctd\u003e2009.0\u003c/td\u003e\r\n      \u003ctd\u003eSports\u003c/td\u003e\r\n      \u003ctd\u003eNintendo\u003c/td\u003e\r\n      \u003ctd\u003e15.75\u003c/td\u003e\r\n      \u003ctd\u003e11.01\u003c/td\u003e\r\n      \u003ctd\u003e3.28\u003c/td\u003e\r\n      \u003ctd\u003e2.96\u003c/td\u003e\r\n      \u003ctd\u003e33.00\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n      \u003cth\u003e4\u003c/th\u003e\r\n      \u003ctd\u003e5\u003c/td\u003e\r\n      \u003ctd\u003ePokemon Red/Pokemon Blue\u003c/td\u003e\r\n      \u003ctd\u003eGB\u003c/td\u003e\r\n      \u003ctd\u003e1996.0\u003c/td\u003e\r\n      \u003ctd\u003eRole-Playing\u003c/td\u003e\r\n      \u003ctd\u003eNintendo\u003c/td\u003e\r\n      \u003ctd\u003e11.27\u003c/td\u003e\r\n      \u003ctd\u003e8.89\u003c/td\u003e\r\n      \u003ctd\u003e10.22\u003c/td\u003e\r\n      \u003ctd\u003e1.00\u003c/td\u003e\r\n      \u003ctd\u003e31.37\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n  \u003c/tbody\u003e\r\n\u003c/table\u003e\r\n\u003c/div\u003e\r\n\r\n\r\n\r\n# Question 1: Top-selling Video Games\r\n\r\n\r\n```python\r\n# Group by name and sum of global sales\r\ntop_selling = df.groupby('Name')['Global_Sales'].sum()\r\n\r\n# Sort by global sales\r\ntop_selling = top_selling.sort_values(ascending=False)\r\n\r\n# Displaying the top 15 games\r\nprint(top_selling.head(15))\r\n```\r\n\r\n    Name\r\n    Wii Sports                        82.74\r\n    Grand Theft Auto V                55.92\r\n    Super Mario Bros.                 45.31\r\n    Tetris                            35.84\r\n    Mario Kart Wii                    35.82\r\n    Wii Sports Resort                 33.00\r\n    Pokemon Red/Pokemon Blue          31.37\r\n    Call of Duty: Modern Warfare 3    30.83\r\n    New Super Mario Bros.             30.01\r\n    Call of Duty: Black Ops II        29.72\r\n    Call of Duty: Black Ops           29.40\r\n    Wii Play                          29.02\r\n    New Super Mario Bros. Wii         28.62\r\n    Duck Hunt                         28.31\r\n    Call of Duty: Ghosts              27.38\r\n    Name: Global_Sales, dtype: float64\r\n    \r\n\r\nMost selling games is Wii Sports with 82.74m global sales, followed by Grand Theft Auto V with 55.92m global sales, followed by the old classic Super Mario Bros. with 45.31m global sales.\r\n\r\n# Question 2: Which Platform was more popular\r\n\r\n\r\n```python\r\n\r\n# Group by platform and sum of global sales\r\ntop_platform = df.groupby('Platform')['Global_Sales'].sum()\r\n\r\n# Sort by platform sales\r\ntop_platform = top_platform.sort_values(ascending=False)\r\n\r\n# Displaying the top 10 platforms\r\nprint(top_platform.head(10))\r\n```\r\n\r\n    Platform\r\n    PS2     1233.46\r\n    X360     969.60\r\n    PS3      949.35\r\n    Wii      909.81\r\n    DS       818.91\r\n    PS       727.39\r\n    GBA      305.62\r\n    PSP      291.71\r\n    PS4      278.10\r\n    PC       254.70\r\n    Name: Global_Sales, dtype: float64\r\n    \r\n\r\nBased on global sales, the most popular platform of all time is Playstation 2 with 1233.46m games being sold.\r\n\r\n# Question 3: Genre Popularity #\r\n\r\n\r\n```python\r\n\r\n\r\n# Group by genre and sum of global sales\r\ntop_genre = df.groupby('Genre')['Global_Sales'].sum()\r\n\r\n# Sort by genre sales\r\ntop_genre = top_genre.sort_values(ascending=False)\r\n\r\n# Displaying the top 10 genres\r\nprint(top_genre.head(10))\r\n```\r\n\r\n    Genre\r\n    Action          1722.84\r\n    Sports          1309.24\r\n    Shooter         1026.20\r\n    Role-Playing     923.83\r\n    Platform         829.13\r\n    Misc             789.87\r\n    Racing           726.76\r\n    Fighting         444.05\r\n    Simulation       389.98\r\n    Puzzle           242.21\r\n    Name: Global_Sales, dtype: float64\r\n    \r\n\r\n# Question 4: Sales by Region\r\n\r\n\r\n```python\r\nregion_sales = df[['NA_Sales','EU_Sales','JP_Sales','Other_Sales']].sum()\r\n\r\n# Creating the bar graph\r\nregion_sales.plot(kind='bar')\r\nplt.title('VGS By Region')\r\nplt.xlabel('Region')\r\nplt.ylabel('Sales (in Mil.)')\r\nplt.show\r\n```\r\n\r\n\r\n\r\n\r\n    \u003cfunction matplotlib.pyplot.show(close=None, block=None)\u003e\r\n\r\n\r\n\r\n\r\n    \r\n![png](README_files/README_16_1.png)\r\n    \r\n\r\n\r\n# Question 5, Hypothesis 1: Relationship between year of release and global sales\r\n\r\n\r\n```python\r\n# Creating the Scatterplot\r\nplt.scatter(df['Year'],df['Global_Sales'])\r\nplt.title('Year of Release vs. Global Sales')\r\nplt.xlabel('YoR')\r\nplt.ylabel('Global Sales (in Mil.)')\r\nplt.show()\r\n```\r\n\r\n\r\n    \r\n![png](README_files/README_18_0.png)\r\n    \r\n\r\n\r\nClearly, there is no positive correlation between the year of release a game released against how it sold. If there was, we should be able to see for a specific year, density of points towards the higher scales of the Global Sales (the Y axis.)\r\n\r\nTherefore, Hypothesis 1 is rejected.\r\n\r\n# Question 6, Hypothesis 2: Relationship between publisher and global sales\r\n\r\n\r\n```python\r\n# Creating the Scatterplot\r\nplt.scatter(df['Publisher'],df['Global_Sales'])\r\nplt.title('Publisher vs. Global Sales')\r\nplt.xlabel('Publisher')\r\nplt.ylabel('Global Sales (in Mil.)')\r\nplt.show()\r\n```\r\n\r\n\r\n    \r\n![png](README_files/README_21_0.png)\r\n    \r\n\r\n\r\nWhoops! It seems we need to do an extra step for this one. Let's try to group them by sales and then sort them.\r\n\r\n\r\n```python\r\n# Grouping by the sum of sales\r\npublisher_vs = df.groupby('Publisher')['Global_Sales'].sum()\r\n\r\n# Sorting by highest selling publisher\r\npublisher_vs = publisher_vs.sort_values(ascending=False)\r\n\r\n# Creating the bar plot\r\npublisher_vs.head(15).plot(kind='bar')\r\nplt.title('Publisher vs. Global Sales')\r\nplt.xlabel('Publisher')\r\nplt.ylabel('Global Sales (in Mil.)')\r\nplt.show()\r\n```\r\n\r\n\r\n    \r\n![png](README_files/README_23_0.png)\r\n    \r\n\r\n\r\nIn the graph above, we immediately observe that Nintendo and EA has had most sales of all times in video games sales. \r\n\r\nWe could go as far to state that since the dataset supports that Nintendo did not achieve those numbers by an irregularity/outlier (i.e one good selling game), but through consistent successful entries, there is definitely something to be learnt from that company.\r\n\r\n# Question 7: Would a Poisson distribution be appropriate to model the sales data?\r\n\r\n## First Calculations\r\n\r\n### Mean and variance calculation\r\n\r\n\r\n```python\r\nmean = df['Global_Sales'].mean()\r\nvar = df['Global_Sales'].var()\r\n```\r\n\r\n### Expected mean and variance calculation\r\n\r\n\r\n```python\r\nexp_mean = mean\r\nexp_var = var\r\n```\r\n\r\n### Showing and comparing the mean \u0026 the variance vs. the expected values\r\n\r\n\r\n```python\r\nprint('Mean sales', mean)\r\nprint('Variance of sales', var)\r\nprint('Expected mean', exp_mean)\r\nprint('Expected variance', exp_var)\r\n```\r\n\r\n    Mean sales 0.5409103185808114\r\n    Variance of sales 2.456568802945086\r\n    Expected mean 0.5409103185808114\r\n    Expected variance 2.456568802945086\r\n    \r\n\r\nTo evaluate that a Poisson distribution can be applied for the model, we need a goodness-of-fit test. That is done by calculating the mean and variance, as we have done above on steps *8.1.1.* and *8.1.2.* and by comparing the observed values to the expected values.\r\n\r\nIf the mean and var have approx. similar values or are equal, then the distribution can be applied. Also for each category, if the mean and var. vs the expected mean and var. have a closer range, then it definitely fits.\r\n\r\nIn this case, there is a quite substantial difference between mean and var. without even comparing the expected mean and var. Regardless, we will still attempt to fit the Poisson Distribution to the data and see how well it fits.\r\n\r\n## Second Calculations\r\n\r\n### Poisson Distribution\r\n\r\n\r\n```python\r\ndef poisson_prob(k, lam):\r\n    return (lam**k)*math.exp(-lam)/math.gamma(k+1)\r\n\r\nmean = np.mean(df['Global_Sales'])\r\n\r\n# Generating a histogram of the sales\r\nn, bins, patches = plt.hist(df['Global_Sales'], bins=50, density=True, alpha=0.5)\r\n\r\n# Calculating the distribution\r\npoisson_dist = [poisson_prob(b,mean) for b in bins]\r\n\r\n# Plotting the distribution over the histogram\r\nplt.plot(bins, poisson_dist, 'r-', linewidth = 1)\r\n\r\n# Labelling the plot\r\nplt.title('Poisson Distribution of Global Sales')\r\nplt.xlabel('Global Sales (in Mil.)')\r\nplt.ylabel('Probability')\r\n```\r\n\r\n\r\n\r\n\r\n    Text(0, 0.5, 'Probability')\r\n\r\n\r\n\r\n\r\n    \r\n![png](README_files/README_36_1.png)\r\n    \r\n\r\n\r\nIn the histogram above, the red line acts as the depiction of the distribution. To be more exact, the red line represents the Poisson probability mass function (PMF).\r\n\r\nThe PMF is a function over a sample of a discrete value X which annotates the probability of value X that is equals to a certain value (f(x) = P[X=x]).\r\n\r\nAs we had already seen on the goodness-for-fit test, the distribution does not work well, as it is clear that the PMF overestimates the frequency of low sales and underestimates that of the high volume of sales. That concludes that Poisson is indeed not a good fit for this dataset.\r\n\r\n\u003e [!NOTE]\r\n\u003e That does not necessarily mean that this data set does not follow *any* probability distribution, just that it does not follow *specifically* a Poisson distribution.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffanisgl%2Fvideo-games-sales-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffanisgl%2Fvideo-games-sales-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffanisgl%2Fvideo-games-sales-data/lists"}