Quantile / percentile example in python
Here’s a good example to understand quantiles in python: import numpy as np d = [1, 1.2, 1.5, 2, 6, 7, 22, 3] q = 0.99 qr = np.quantile(d, q) print(f”{q*100}% less than {qr}”)
Here’s a good example to understand quantiles in python: import numpy as np d = [1, 1.2, 1.5, 2, 6, 7, 22, 3] q = 0.99 qr = np.quantile(d, q) print(f”{q*100}% less than {qr}”)
Here we calculate 0.9th quantile of each column in our dataframe: q = 0.9 for column in df: qr = df[column].quantile(q) print(f”{q*100}% are lower than {qr}”) Here’s a good example to understand quantiles.