# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd

# +
# Reading csv file 

apps = pd.read_csv(r'C:/Users/Rishabh/Desktop/pd/ml/appstore.csv')
# -

apps.head(5)

# +
#Dropping rows having Nan 

apps=apps.dropna(how='any')
apps

# +
#Dropping unnecessary columns

apps.drop(['URL','ID','Subtitle','Icon URL','Description','Developer','Languages','Primary Genre'],axis=1,inplace=True)
apps.head(5)

# +
#Renaming columns 

apps.rename(columns={'Average User Rating':'Avg','User Rating Count':'UserRating','In-app Purchases':'Inapp','Original Release Date':'Ordate','Current Version Release Date':'crdate'},inplace=True)
# -

apps.head(5)

# +
# Checking for the number of months since last update


apps['Ordate'] = pd.to_datetime(apps.Ordate)
apps['crdate'] = pd.to_datetime(apps.crdate)
startyear = apps['Ordate'].dt.year
startmonth = apps['Ordate'].dt.month
endyear = apps['crdate'].dt.year
endmonth = apps['crdate'].dt.month
nummonths =  (endyear - startyear)*12 + (endmonth - startmonth)
apps = apps[nummonths<=6]

# -

apps.head(5)

# +
# Games with more than 200 UserRating and more than 4.0 AverageRating

apps=apps[apps['UserRating']>=200]
apps=apps[apps['Avg']>=4]
apps.head(5)

# +
# Removing words ['Games','Entertainment'] to avoid confusion

apps.Genres = apps.Genres.str.replace('Games,','').str.replace('Entertainment','')
apps.head(5)

# +
# Grouping games with Puzzle/Board Genre

puzzlegame = apps[apps.Genres.str.contains('Puzzle' or 'Board')]
# -

puzzlegame

# +
# Grouping games with Family/Education Genre

familygame = apps[apps.Genres.str.contains('Family' or 'Education')]
# -

familygame

# +
# Grouping games with Adventure/Role/Role Playing Genre

adventuregame =  apps[apps.Genres.str.contains('Adventure' or 'Role' or 'Role Playing')]
# -

adventuregame

# +
# Grouping games with Action Genre


actiongame =  apps[apps.Genres.str.contains('Action')]
# -

actiongame

# +
# Inferences 
# -

p=puzzlegame.UserRating.mean()

f=familygame.UserRating.mean()

ad=adventuregame.UserRating.mean()

ac=actiongame.UserRating.mean()

import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import numpy as np

# +

# Simple Bar Graph plot of Average User Rating

 
objects = ('Puzzle Games', 'Family Games', 'Adventure Games', 'Action Games')
y_pos = np.arange(len(objects))
avgUserRating = [p,f,ad,ac]
 
plt.bar(y_pos, avgUserRating, align='center', alpha=0.7)
plt.xticks(y_pos, objects)
plt.ylabel('Average User Rating')
plt.title('Plot of Average User Rating')
 
plt.show()

StarcoderdataJupyterScriptsDedupFiltered