<jupyter_start><jupyter_text>20 Years of GamesTutorial is based on https://www.dataquest.io/blog/pandas-python-tutorialAuthor: yvesbeutlerDate: 13-02-2019<jupyter_code>import numpy as np
import pandas as pd

# used to check ifNaN()
import math

reviews = pd.read_csv("../../data/ign.csv")
# remove first unwanted column
reviews = reviews.loc[:,"score_phrase":] # better than reviews.iloc[:,1:]

reviews.head()
some_reviews = reviews.iloc[10:20,]
some_reviews.head()

# info: some_reviews.loc[9:21,:] doesn't throw an error as expected
# create a DataFrame out of three Series


s1 = pd.Series([5371, '<NAME>', 'Junior']).
s2 = pd.Series([4365, '<NAME>', 'Lead']).to_frame()
s3 = pd.Series([1925, '<NAME>', 'Professional']).to_frame()

x = [s1, s2, s3]
df = pd.DataFrame(x,columns=['id', 'nameds', 'experience'])
# why can't I rename my cols..? :-(

df
# get the mean score of all games
reviews['score'].mean()

# get the means of all numerical columns
reviews.mean()<jupyter_output><empty_output><jupyter_text>Statistical CorrelationAs a rule of thumb, the following guidelines on strength of relationship are often useful (though many experts would somewhat disagree on the choice of boundaries).| Value of r                 | Strength of relationship ||----------------------------|--------------------------|| -1.0 to -0.5 or 1.0 to 0.5 | Strong                   || -0.5 to -0.3 or 0.5 to 0.3 | Moderate                 || -0.3 to -0.1 or 0.3 to 0.1 | Weak                     || -0.1 to 0.1                | None or very weak        |Correlation is only appropriate for examining the relationship between meaningful quantifiable data (e.g. air pressure, temperature) rather than categorical data such as gender, color etc.<jupyter_code># check correlation of our attributes
reviews.corr()
# create Boolean Series to filter with
score_filter = reviews['score'] > 8

reviews[score_filter]
# 1. What is the first game ever released?

min_year = reviews['release_year'].min()
year_filter = reviews['release_year'] == min_year
filtered_reviews = reviews[year_filter]

min_month = filtered_reviews['release_month'].min()
month_filter = filtered_reviews['release_month'] == min_month
filtered_reviews = filtered_reviews[month_filter]

min_day = filtered_reviews['release_day'].min()
day_filter = filtered_reviews['release_day'] == min_day
filtered_reviews = filtered_reviews[day_filter]

#filtered_reviews[['title','release_year','release_month','release_day']]
filtered_reviews
# 2. Do game scores vary from year to year?

i = 1970
series_list = []
while (i < 2017):
    year_reviews = reviews[reviews['release_year'] == i]
    yearly_score = (year_reviews['score'].mean())
    if (math.isnan(yearly_score) == False):
        series = pd.Series([i, yearly_score])
        series_list.append(series)
    i += 1

yearly_scores = pd.DataFrame(series_list)

yearly_scores.plot(kind='bar',x=0,y=1)
# 3. What's the platform with the highest average reviews?

reduced_reviews = reviews[['platform', 'score']]
grouped_reviews = reduced_reviews.groupby('platform')
platforms = grouped_reviews['score'].agg(np.mean)

# sort series
platforms = platforms.sort_values(ascending=False)
platforms.head(10)
# 4. Are blockbuster games released at a specific time of the year?<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14359598418010344, 'fraction_numerical': 0.024946759963492545, 'mean_word_length': 4.177952755905512, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '466082', 'license': 'MIT', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1033, 'n_words': 296, 'path': 'src/notebooks/20 Years of Games.ipynb', 'repo_name': 'yvesbeutler/tyrannosaurus', 'size': '3307'}