<jupyter_start><jupyter_text><NAME> Research question/interests How does game categories affects the ratings of a game? A rare research insight on how gaming categories (i.e adventure, action) affects the ratings of a game.  TASK 1  This is the summary (Range index, non-null counts, index Dtype, memory usage) of our dataframe/set:<jupyter_code>import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import missingno
%matplotlib inline

df = pd.read_csv('../data/raw/android-games.csv')
df.info()
df.head()

df['rank'] = df['rank'].astype('str')

df['TR'] = df['total ratings'].astype('category')
df['AV'] = df['average rating'].astype('category')
df['5 star ratings'] = df['5 star ratings'].astype('category')
df['4 star ratings'] = df['4 star ratings'].astype('category')
df['3 star ratings'] = df['3 star ratings'].astype('category')
df['2 star ratings'] = df['2 star ratings'].astype(str).str.strip().astype('category')
df['1 star ratings'] = df['1 star ratings'].astype('category')
df['CT'] = df['category'].astype('category')<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 1730 entries, 0 to 1729
Data columns (total 15 columns):
 #   Column            Non-Null Count  Dtype  
---  ------            --------------  -----  
 0   rank              1730 non-null   int64  
 1   title             1730 non-null   object 
 2   total ratings     1730 non-null   int64  
 3   installs          1730 non-null   object 
 4   average rating    1730 non-null   int64  
 5   growth (30 days)  1730 non-null   float64
 6   growth (60 days)  1730 non-null   float64
 7   price             1730 non-null   float64
 8   category          1730 non-null   object 
 9   5 star ratings    1730 non-null   int64  
 10  4 star ratings    1730 non-null   int64  
 11  3 star ratings    1730 non-null   int64  
 12  2 star ratings    1730 non-null   int64  
 13  1 star ratings    1730 non-null   int64  
 14  paid              1730 non-null   bool   
dtypes: bool(1), float64(3), int64(8), object(3)
memory usage: 191.0+ KB<jupyter_text>These are the types of datas in python language of our dataframe<jupyter_code>import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import missingno
%matplotlib inline


df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 1730 entries, 0 to 1729
Data columns (total 18 columns):
 #   Column            Non-Null Count  Dtype   
---  ------            --------------  -----   
 0   rank              1730 non-null   object  
 1   title             1730 non-null   object  
 2   total ratings     1730 non-null   int64   
 3   installs          1730 non-null   object  
 4   average rating    1730 non-null   int64   
 5   growth (30 days)  1730 non-null   float64 
 6   growth (60 days)  1730 non-null   float64 
 7   price             1730 non-null   float64 
 8   category          1730 non-null   object  
 9   5 star ratings    1730 non-null   category
 10  4 star ratings    1730 non-null   category
 11  3 star ratings    1730 non-null   category
 12  2 star ratings    1730 non-null   category
 13  1 star ratings    1730 non-null   category
 14  paid              1730 non-null   bool    
 15  TR                1730 non-null   category
 16  AV                1730 n[...]<jupyter_text>These are the first five games in our dataframe:<jupyter_code>df.head()<jupyter_output><empty_output><jupyter_text>And these are the last five games in our dataframe:<jupyter_code>df.tail()<jupyter_output><empty_output><jupyter_text>These are the names of every columns in our dataframe:<jupyter_code>df.columns<jupyter_output><empty_output><jupyter_text>The next table describes the basic statistics of our numerical parts of the dataset. These includes the average values of each columns (for example, the average rating for all games on this list is about 3.9 star, ranging from 1 to 5 stars). These are the complete explanation regarding each column: Count = Total rumber of Rows for a column. Mean = Average value of a data (Total numerical value of the column divided by how many datas are there in that column) Std = Standard Deviation tells us how far data points scattered relating to our Mean value. High standard deviation i.e as the std for Total Ratings) means lots of datas are scattered far away from its mean value of 1.064e+06. Min = The absolute minimum value in that column. Max = The absolute maximum value in that column. 25% = This tells us how many values are less than 25% percent. 50% = This tells us how many values are less than 50% percent. 75% = This tells us how many values are less than 75% percent.<jupyter_code>pd.set_option('precision', 3)
df.describe(include = [np.number]).T<jupyter_output><empty_output><jupyter_text>These are the total number of NaN datas in each column (NaN = Unavailable Datas): For our dataset, there's no Unavailable Datas.<jupyter_code>df.isnull().sum()<jupyter_output><empty_output><jupyter_text>And Last but not Least, the Correlation heatmap. For my research question, we will focus on columns related to ratings, including the total ratings, the average rating, and the ratings of each star.<jupyter_code>df = pd.read_csv('../data/raw/android-games.csv')

corrmap = df.corr()
sns.heatmap(corrmap, xticklabels = corrmap.columns, yticklabels = corrmap.columns, annot=True, cmap=sns.diverging_palette(220, 20, as_cmap=True))
sns.set(rc = {'figure.figsize':(18,10)}, style = 'white')<jupyter_output><empty_output><jupyter_text>TASK 2 Load Data<jupyter_code>df = pd.read_csv('../data/raw/android-games.csv')

df<jupyter_output><empty_output><jupyter_text>Cleaning the Data *Mr. Clean clean the data* *Mr. Clean wipe unecessary stuff*<jupyter_code>df_clean = df.drop(["installs","growth (30 days)","growth (60 days)", "price", "paid"], axis=1)
df_clean<jupyter_output><empty_output><jupyter_text>Data Wrangling We then wrangle the data by sorting its values<jupyter_code>df_sort = df_clean.sort_values("category").reset_index(drop=True)

df_sort<jupyter_output><empty_output><jupyter_text>Data Processing Then we Process the data by renaming its columns to provide better output view<jupyter_code>df_rename = df_sort.rename(columns=
            {"total ratings": "Total amount of raters",
            "5 star ratings": "5 stars",
            "4 star ratings": "4 stars",
            "3 star ratings": "3 stars",
            "2 star ratings": "2 stars",
            "1 star ratings": "1 star",
            "rank": "Rank of game in Google Playstore"})

df_rename<jupyter_output><empty_output><jupyter_text>TASK 3 The First task is to make and test our method chain function.<jupyter_code>def load_and_process(url_or_path_to_csv_file):

    # Method Chain 1 (Load data and deal with missing data)

    df1 = (
          pd.read_csv('../data/raw/android-games.csv')
          .dropna(how="any")
          .sort_values("category")
          .reset_index(drop=True)
      )

    # Method Chain 2 (Create new columns, drop others, and do processing)

    df2 = (
          df1
      )

    # Make sure to return the latest dataframe

    return df2 

load_and_process('../data/raw/android-games.csv')<jupyter_output><empty_output><jupyter_text>Afterwards, we copy and paste the same function to a new .py file called project_function_3. We will then import that function module into here.<jupyter_code>import project_function_3
df = project_function_3.load_and_process('../data/raw/android-games.csv')
df<jupyter_output><empty_output><jupyter_text>TASK 4 Here we will conduct our analysis and finally answer my research question (How does game categories affects the ratings of a game?) First of all, we will define three graphs, based on the amount of ratings and game categories. The first one would be the five star ratings (maximum amount of star you can give to rate).  NOTE: We are going to use the dataset that we have wrangled and processed back in Task 2.<jupyter_code># make seaborn barplot
sns.barplot(x = '5 stars', y = 'category', data = df_rename)
 
# Show the plot
plt.show()<jupyter_output><empty_output><jupyter_text>From the first graph, we can conclude that Action Games wins the medal in most 5 star ratings, followed second by Casual, then Strategy/RTS.  But now we're going to graph three star ratings (median point of star you can give) against each game categories and see in another perspective:<jupyter_code># make seaborn barplot
sns.barplot(x = '3 stars', y = 'category', data = df_rename)
 
# Show the plot
plt.show()<jupyter_output><empty_output><jupyter_text>It seems that three star ratings also have the previous trios as the winner. This means that lots of people rated Action, Casual, and RTS games as both 5 stars and 3 stars. This means that none of these categories actually excels against other types of games, they just have lots of more people to play and rate. Last but not least, we're going to graph the minimum amount of stars you can give (1 star) against each game categories:<jupyter_code># make seaborn barplot
sns.barplot(x = '1 star', y = 'category', data = df_rename)
 
# Show the plot
plt.show()<jupyter_output><empty_output><jupyter_text>From the previous 3 graphs, it seems like the all three have similar plottings, with Action Games having the most ratings, and Educational Games the least. Unfortunately this means that while Action Games has the highest 5 stars, but it also highest 1 stars. This nullifies the hypothesis that Action Games have the highest ratings overall comparing to other categories, just because it has higher ratings in the 5 stars graph. To verify this, we will show the Average Ratings for each Game Categories:<jupyter_code># make seaborn barplot
sns.barplot(x = 'average rating', y = 'category', data = df_rename)
 
# Show the plot
plt.show()<jupyter_output><empty_output><jupyter_text>As we might have predicted, every game category have similar average ratings. There is at most a range of 0.16 stars between the highest category (Action) and lowest (Music). Quite a trivial difference. Now we take a look at how many people rate for each game category:<jupyter_code># make seaborn barplot
sns.barplot(x = 'Total amount of raters', y = 'category', data = df_rename)
 
# Show the plot
plt.show()<jupyter_output><empty_output><jupyter_text>From this graph, it shows how the trios (Action, Casual, Strategy) have indeed have the biggest amount of raters. This explains how Action games have the most raters in all 1, 3, and 5 star graphs, while educational and music have the least values in every graph. Although we might be able to prove that the total amount of raters correlates proportionally with for each star, instead to the game's category. This might be confusing, so lets take a sample scatter plot between the amount of raters and the number of 3 and 5 stars:<jupyter_code>x = sns.regplot(x = '3 stars', y = 'Total amount of raters', data = df_rename)
x = sns.regplot(x = '5 stars', y = 'Total amount of raters', data = df_rename)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup