text_html_output_1.png
import pandas as pd

import plotly.express as px

import plotly.graph_objs as go

games = pd.read_csv('/kaggle/input/videogamesales/vgsales.csv')

top_10_publishers = games.Publisher.value_counts().sort_values(ascending=False).head(10)
fig = px.pie(top_10_publishers,
             values= top_10_publishers.values,
             names= top_10_publishers.index,
             title='Top 10 Games Publishers')
fig.update_traces(textposition='inside', textinfo='percent+label')
fig.show()

def top_sales(df, region):
    if region == 'JP_Sales':
        japan = games.groupby('Name')['JP_Sales'].sum().reset_index().sort_values('JP_Sales', ascending=False).head(10)
        return japan
    elif region == 'EU_Sales':
        eu = games.groupby('Name')['EU_Sales'].sum().reset_index().sort_values('EU_Sales', ascending=False).head(10)
        return eu
    elif region == 'NA_Sales':
        na = games.groupby('Name')['NA_Sales'].sum().reset_index().sort_values('NA_Sales', ascending=False).head(10)
        return na
    elif region == 'Global_Sales':
        globe = games.groupby('Name')['Global_Sales'].sum().reset_index().sort_values('Global_Sales', ascending=False).head(10)
        return globe
    else:
        other = games.groupby('Name')['Other_Sales'].sum().reset_index().sort_values('Other_Sales', ascending=False).head(10)
        return other

top10_JP_sales = top_sales(games, 'JP_Sales')

top10_EU_sales = top_sales(games, 'EU_Sales')

top10_NA_sales = top_sales(games, 'NA_Sales')

top10_Global_sales = top_sales(games, 'Global_Sales')

top10_Other_sales = top_sales(games, 'Other_Sales')

fig = go.Figure(data=[go.Bar(x=top10_JP_sales.Name, y=top10_JP_sales.JP_Sales)], layout_title_text='Top 10 Sales Games In Japan')

fig = go.Figure(data=[go.Bar(x=top10_EU_sales.Name, y=top10_EU_sales.EU_Sales)], layout_title_text='Top 10 Sales Games In EU')

fig = go.Figure(data=[go.Bar(x=top10_NA_sales.Name, y=top10_NA_sales.NA_Sales)], layout_title_text='Top 10 Sales Games In NA')

fig = go.Figure(data=[go.Bar(x=top10_Global_sales.Name, y=top10_Global_sales.Global_Sales)], layout_title_text='Top 10 Sales Games Global')

fig = go.Figure(data=[go.Bar(x=top10_Other_sales.Name, y=top10_Other_sales.Other_Sales)], layout_title_text='Top 10 Sales Games Other')

publication_distr = games.Year.value_counts().sort_values(ascending=False)
fig = px.bar(publication_distr, x=publication_distr.index, y=publication_distr.values, title='Year of Games Releasing & Distribution')
fig.show()