# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
r=pd.read_csv('/kaggle/input/windows-store/msft.csv',parse_dates=['Date'])
r.head()
r[['people_ratings']]=r[['No of people Rated']]
del r['No of people Rated']
r.head()
r.info()
r.isnull().sum()
#identifying the missing row
d=r[r['Name'].isnull()]
d
#dropping missing row
r.dropna(inplace=True)
r.isnull().sum()
r.tail()
r['Rating'].value_counts()/len(r)
"""
Most of the apps have a rating of 4(approx 24%)
"""
r['Category'].value_counts()/len(r)
"""
Most of the apps are of Music(approx 14%) and Books(approx 13%) Category.
"""
#denoting non free values as paid
r.loc[r['Price'] != 'Free', 'Price'] = 'Paid' 
r['Price'].value_counts()/len(r)*100
"""
Majority of the apps are free(97%)
"""
#finding highest rated apps in each category
r[r['Rating']>=1.0].groupby(['Category']).max()
"""
Since books,business and developer tools category contains the highest rated apps which are paid so it is seen that price doesn't affect the app rating it is generally determined by app performance.
"""
#mean rating and no of people rated in each category
r.groupby('Category')[['Rating','people_ratings']].mean()
"""
Government and politics category have the highest mean rating.

Multimedia Design category have the highest no of people_ratings.
"""
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
import plotly
plotly.offline.init_notebook_mode(connected = True)
sns.barplot('Price','Rating',data=r)
plt.title("Distribution of Apps")
"""
Rating of free is more because of more number of free apps.
"""
#finding majority of paid and free apps in each category
plt.figure(figsize=(20,10))
fig=px.scatter(r,'Category',color='Price')
fig.show()
"""
In this graph it is depicted that most of the paid apps exist in Books,Business and Developer tools categories.
"""
#displaying proporations of total ratings of people of each category
fig=px.pie(r,values='people_ratings',names='Category',title="Distribution of Categories according to user's ratings")
fig.show()
#finding rating trend of apps given by users in each category
plt.figure(figsize=(30,20))
sns.lineplot('Category','people_ratings',data=r,hue='Rating',marker='o',legend=False)
plt.xticks(rotation=90)
plt.legend(title='Ratings',loc='upper right',labels=[1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0])
plt.title('Distribution of Categories based on rating count given by users',fontsize=13)
fig = px.scatter(r, x="Rating", y="people_ratings", 
                 color="Category", 
                 hover_data=['people_ratings','Rating','Category','Price'], 
                 title = "Visualization of each app features of Window Store")
fig.show()
"""
From the above graph we can say that what are the user's feedback based on all features of dataset of each app.
"""
#setting date as index for time series analysis
r=r.set_index('Date')
r['Month']=r.index.month
r['Year']=r.index.year
r['Day']=r.index.day
#determining most number of downloads per year
fig=px.pie(r,values='people_ratings',names='Year',title='Number of ratings on yearly basis')
fig.show()
"""
Since 2016 has most number of user ratings so it has been confirmed that 2016 has the more number of app downloads as ratings are only given by the user after downloading the app and using it.
"""
fig=px.pie(r,values='people_ratings',names='Month',title='Number of ratings on monthly basis')
fig.show()
"""
10 means October month has most number of ratings so most number of downloads.
"""
fig=px.pie(r,values='people_ratings',names='Day',title='Number of ratings on daily basis')
fig.show()
"""
Day 30 i.e.end of the month has the most number of ratings so most number of downloads.
"""
"""
**If you like this notebook do upvote it.**

Do provide your valuable feedback.

Do checkout my other notebooks at https://www.kaggle.com/tmchls
"""