text_plain_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

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

dfsorted = df.sort_values('Global_Sales', ascending=False)
top20 = dfsorted.head(20)
top20

NAsorted= df.sort_values('NA_Sales', ascending=False)
NA_median = NAsorted['NA_Sales'].median()
surrounding_games = NAsorted.loc[(NAsorted['NA_Sales'] >= NA_median) & (NAsorted['NA_Sales'] <= NA_median)].head(10)

print(NA_median)

surrounding_games

df_sorted = df.sort_values('Global_Sales', ascending=False)
na_sales_top_game = df_sorted['NA_Sales'].iloc[0]
mean_na_sales = df_sorted['NA_Sales'].mean()
std_na_sales = df_sorted['NA_Sales'].std()
num_std = (na_sales_top_game - mean_na_sales) / std_na_sales

grouped_by_platform = df.groupby('Platform')['Global_Sales'].mean().reset_index()
wii_data = grouped_by_platform.loc[grouped_by_platform['Platform'] == 'Wii']
mean_except_wii = grouped_by_platform.loc[grouped_by_platform['Platform'] != 'Wii']['Global_Sales'].mean()
if wii_data['Global_Sales'].values > mean_except_wii:
    print('The average number of sales for the Nintendo Wii is higher than the other platforms.')
else:
    print('The average number of sales for the Nintendo Wii is not higher than the other platforms.')