# --------------
#Importing header files
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns





#Code starts here
data = pd.read_csv(path)
data.hist(['Rating'])
data = data[data['Rating']<=5]
data.hist(['Rating'])
#Code ends here


# --------------
# code starts here
total_null = data.isnull().sum()
percent_null = (total_null/data.isnull().count())
missing_data = pd.concat([total_null,percent_null],keys=['Total','Percent'],axis=1)
print(missing_data)

data.dropna(inplace=True)

total_null_1 = data.isnull().sum()
percent_null_1 = (total_null_1/data.isnull().count())
missing_data_1 = pd.concat([total_null_1,percent_null_1],keys=['Total','Percent'],axis=1)
print(missing_data_1)
# code ends here


# --------------

#Code starts here
plt.figure(figsize=(10,20))
catplot = sns.catplot(x = "Category", y = "Rating", data=data, kind="box",height=10)
catplot.set_xticklabels(rotation=90)
plt.title('Rating vs Category [BoxPlot]',size = 20)
#Code ends here


# --------------
#Importing header files
from sklearn.preprocessing import MinMaxScaler, LabelEncoder

#Code starts here
print(data['Installs'])
data['Installs'] = data['Installs'].str.replace('+','')
data['Installs'] = data['Installs'].str.replace(',','')
data['Installs'] = data['Installs'].astype('int32')
le = LabelEncoder()
data['Installs'] = le.fit_transform(data['Installs'])
graph = sns.regplot(data['Installs'],data['Rating'],data=data)
graph.set_title('Rating vs Installs [Boxplot]')
plt.show()
#Code ends here



# --------------
#Code starts here
print(data['Price'].value_counts())
data['Price'] = data['Price'].str.replace('$','')
data['Price'] = data['Price'].astype('float32')
graph2 = sns.regplot(data['Price'],data['Rating'],data=data)
graph2.set_title('Rating vs Price [RegPlot]')
#Code ends here


# --------------

#Code starts here
print(len(data['Genres'].unique()), "genres")
data['Genres'] = data['Genres'].str.split(';').str[0]
gr_mean = data[['Genres','Rating']].groupby(['Genres'],as_index=False).mean()
print(gr_mean.describe())
gr_mean=gr_mean.sort_values('Rating')
print(gr_mean.head(1))
print(gr_mean.head(1))

#Code ends here


# --------------

#Code starts here
data['Last Updated'] = pd.to_datetime(data['Last Updated'])
data['Last Updated Days'] = (data['Last Updated'].max()-data['Last Updated']).dt.days
plt.figure(figsize = (10,10))
sns.regplot(x="Last Updated Days", y="Rating",color='lightpink',data=data)
plt.title('Rating vs Last Updated [Regplot]',size =20)
#Code ends here



[((12, 7, 12, 24), 'pandas.read_csv', 'pd.read_csv', ({(12, 19, 12, 23): 'path'}, {}), '(path)', True, 'import pandas as pd\n'), ((23, 15, 23, 83), 'pandas.concat', 'pd.concat', (), '', True, 'import pandas as pd\n'), ((30, 17, 30, 89), 'pandas.concat', 'pd.concat', (), '', True, 'import pandas as pd\n'), ((38, 0, 38, 27), 'matplotlib.pyplot.figure', 'plt.figure', (), '', True, 'import matplotlib.pyplot as plt\n'), ((39, 10, 39, 84), 'seaborn.catplot', 'sns.catplot', (), '', True, 'import seaborn as sns\n'), ((41, 0, 41, 51), 'matplotlib.pyplot.title', 'plt.title', (), '', True, 'import matplotlib.pyplot as plt\n'), ((54, 5, 54, 19), 'sklearn.preprocessing.LabelEncoder', 'LabelEncoder', ({}, {}), '()', False, 'from sklearn.preprocessing import MinMaxScaler, LabelEncoder\n'), ((56, 8, 56, 62), 'seaborn.regplot', 'sns.regplot', (), '', True, 'import seaborn as sns\n'), ((58, 0, 58, 10), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((68, 9, 68, 60), 'seaborn.regplot', 'sns.regplot', (), '', True, 'import seaborn as sns\n'), ((90, 23, 90, 59), 'pandas.to_datetime', 'pd.to_datetime', ({(90, 38, 90, 58): "data['Last Updated']"}, {}), "(data['Last Updated'])", True, 'import pandas as pd\n'), ((92, 0, 92, 29), 'matplotlib.pyplot.figure', 'plt.figure', (), '', True, 'import matplotlib.pyplot as plt\n'), ((93, 0, 93, 74), 'seaborn.regplot', 'sns.regplot', (), '', True, 'import seaborn as sns\n'), ((94, 0, 94, 54), 'matplotlib.pyplot.title', 'plt.title', (), '', True, 'import matplotlib.pyplot as plt\n')]