Game Data Analysis Part 1

 avatar
shebom
python
a year ago
1.7 kB
8
Indexable
#https://drive.google.com/file/d/1BlMmC4c5a11jFB8hhKo03Vq2WYH1sZgV/view?usp=sharing 
#installing all the dependencies
!pip install pandas matplotlib seaborn plotly

from google.colab import drive
drive.mount('/content/drive')

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px

# Define a boolean variable
is_true = True

# Use the not operand to negate the boolean value
is_not_true = not is_true

# Print the results
print("Original value:", is_true)
print("Negated value:", is_not_true)

# Load the dataset
df = pd.read_csv('/game_data.csv')

# Display basic information about the dataset
print(df.info())
# Display 1 line space in between
print('\n')
# Display the first few rows of the dataset
print(df.head())
# Display 1 line space in between
print('\n')
# Display the first few rows of the dataset
print(df.tail())

df

# Drop rows with missing values
df = df.dropna()

# Convert 'Year_of_Release' to integer
df['Year'] = df['Year'].astype(int)

# Group the DataFrame 'df' by 'Publisher' and sum the 'Global_Sales' for each publisher
top_publishers = df.groupby('Publisher')['Global_Sales'].sum().nlargest(10)
# Set up the figure size for the plot
plt.figure(figsize=(10, 6))
# Create a bar plot using Seaborn, where x-values are the global sales values, y-values are the publisher names,
# and use the 'viridis' color palette for the bars
sns.barplot(x=top_publishers.values, y=top_publishers.index, palette='viridis')
# Set the title of the plot
plt.title('Top 10 Publishers by Global Sales')
# Set labels for the x and y axes
plt.xlabel('Global Sales (in millions)')
plt.ylabel('Publisher')
# Display the plot
plt.show()
Editor is loading...
Leave a Comment