def frequecy_table(var_name):
    table = pd.DataFrame(app[var_name].value_counts())
    table.reset_index(level = 0, inplace = True)
    table['percentage'] = table[var_name]/table[var_name].sum()
    return table

frequecy_table('category')

"""
Explanation: <b>Categorical Variables</b>
<p>In this part, frequency table for each categorical variable is made.</p>

<b>Category</b>
End of explanation
"""


frequecy_table('multiple languages')

"""
Explanation: <b>Multiple Languages</b>
End of explanation
"""


frequecy_table('price')

"""
Explanation: <b>Price</b>
End of explanation
"""


frequecy_table('multiple devices')

"""
Explanation: <p>We can find that most apps are free, as a result, we may discard variable 'price' in the following analysis.</p>

<b>Multiple Devices</b>
End of explanation
"""


def statistics(var_name):
    table = []
    for each in app[var_name]:
        if each != '' and float(each) > 0:
            table.append(float(each))
    mean = np.mean(table)
    var = np.var(table)
    median = np.median(table)
    range_1 = np.max(table) - np.min(table)
    min_1 = np.min(table)
    max_1 = np.max(table)
    dict_1 = {'mean':mean, 'var':var, 'median':median, 'range':range_1, 'min':min_1, 'max':max_1}
    summary_table = pd.DataFrame.from_dict(dict_1, orient='index').T
    return summary_table

statistics('current rating')

def plot_density(var_name):
    table = []
    for each in app[var_name]:
        if each != '' and float(each) > 0:
            table.append(float(each))
    table = pd.DataFrame(table)
    table.plot(kind = "density") 
    plt.legend(labels = [var_name], loc='upper left')
    plt.title('Distribution of %s'%(var_name))
    plt.show()

plot_density('current rating')

"""
Explanation: <p>We can find that most apps are multiple devices, as a result, we may discard variable 'multiple devices' in the following analysis.</p>

<b>Continuous Variables</b>
<p>In this part, for all continuous variables, mean, var, median, range, min value and max value are calculated, density plot is also made for each continuous variable.</p>

<b>Current Rating</b>
End of explanation
"""


statistics('current reviews')

plot_density('current reviews')

"""
Explanation: <b>Current Reviews</b>
End of explanation
"""


statistics('overall rating')

plot_density('overall rating')

"""
Explanation: <b>Overall Rating</b>
End of explanation
"""


statistics('overall reviews')

plot_density('overall reviews')

"""
Explanation: <b>Overall Reviews</b>
End of explanation
"""


