I have a data frame as given below:
cust_id state city buy_times
1. 123 delhi xyz 2
2. 234 haryana ggm 4
3. 345 delhi abc 7
4. 456 AP asd 3
So on and so forth.
I need to calculate the percentage of sales by each city and state.
df = data.groupby(['state','city'])['buy_times].sum()
Using this command, I have got the total number of sales by each city and state. But I am unable to calculate the percentage of the same.