1# credit to the source link
2
3import numpy as np
4
5quant = np.quantile(arr, q)
6
7# arr: array - like object (list or np.array)
8# q: float from 0 to 1
1>>> np.percentile(df.time_diff, 25) # Q1
20.48333300000000001
3
4>>> np.percentile(df.time_diff, 50) # median
50.5
6
7>>> np.percentile(df.time_diff, 75) # Q3
80.51666699999999999
9