I have a dataframe with Yes/no answer in the column 'quality','price','time'.
I transformed in 1 and 0 and grouped
grouped = df.group.by(['country'])[['quality','price','time']].sum() to get only the 'Yes' answers and the result is:
| country | quality | price | time |
|---|---|---|---|
| FRANCE | 5 | 4 | 3 |
| GERMANY | 3 | 2 | 6 |
| UK | 2 | 1 | 4 |
I would like to know how to divide each values in groupby for the size(N total) of each country respondents, in my case FRANCE = 9 , GERMANY = 11, UK = 12.
I know that i can select single group and make operations with it:
france = country_split.loc[['FRANCE']]
(france/9)*100
but it is possible to make operations for the entire group in one time?