I have a dataframe df that is indexed by customer id. and includes:
df=['Customer ID', 'Sales' ,'Product code' ,'Price']
]: https://i.stack.imgur.com/vP8Gy.png
I want to create a column Quantile, which which calculates for each customer id the corresponding quantiles from the range (0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,0.95,1)
of the price column
df=['Customer ID', 'Sales','Product code', 'Price', 'Quantiles Price']
Customer ID Sales Product code Price
1218 13 46 2
1219 14 47 3
1220 15 48 4
1221 16 49 5
1222 17 50 6
1223 18 51 7
1224 19 52 8
1225 20 53 9
1226 21 54 10
1227 22 55 11
1228 23 56 12
1229 24 57 13
so the final df will include a new column called quantile of the price for each corresponding customer id:
Customer ID Sales Product code Price Price Quantiles
1218 13 46 2 7
1219 14 47 3 2
1220 15 48 4 3
1221 16 49 5 2
1222 17 50 6 2
1223 18 51 7 4
1224 19 52 8 7
1225 20 53 9 7
1226 21 54 10 11
1227 22 55 11 11
1228 23 56 12 11
1229 24 57 13 11
Anyone can advise what function i can use to get this?
Thank you in advance.