01 Calculating percentile#

%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/Ngyt8Q5tWkU/" frameborder="0" allowfullscreen></iframe>
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
from scipy import stats

khanacademy

Calculating percentile fig 1Calculating percentile fig 2

percentile-vs-quantile-vs-quartile

x = np.array(1 * [1] + 2 * [2] + 1 * [3] + 1 * [4] + 2 * [5] + 1 * [6] + 5 * [7] + 1 * [9])
for i in [40, 55, 70, 85]:
    percentile = np.percentile(x, i)
    if round(percentile) == 6:
        print(i, percentile)
55 6.15
Series(x).plot(kind='hist')
<AxesSubplot:ylabel='Frequency'>
../_images/01 Calculating percentile_8_1.png
plt.hist(x)
plt.xlabel('Hours a day')
plt.ylabel('Drivers')
plt.show()
../_images/01 Calculating percentile_9_0.png
# TODO: fix plot gap and create a dot plot instead of histogram