I have a very simple dataframe:
df = pd.DataFrame([5,7,10,15,19,21,21,22,22,23,23,23,23,23,24,24,24,24,25], columns=['val'])
df.median() = 23 which is right because from 19 values in the list, 23 is 10th value (9 values before 23, and 9 values after 23)
I tried to calculate 1st and 3rt quartile as:
df.quantile([.25, .75])
val
0.25 20.0
0.75 23.5
I would have expected that from 9 values bellow median that 1st quartile should be 19, but as you can see above, python says it is 20. Similarly, for 3rd quartile, fifth number from right to left is 24, but python shows 23.5.
How does pandas calculates quartile?
Original question is from the following link: https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/box-whisker-plots/a/identifying-outliers-iqr-rule