Pandas: How to find percentage of group members type per subgroup?
问题 ( Data sample and attempts at the end of the question ) With a dataframe such as this: Type Class Area Decision 0 A 1 North Yes 1 B 1 North Yes 2 C 2 South No 3 A 3 South No 4 B 3 South No 5 C 1 South No 6 A 2 North Yes 7 B 3 South Yes 8 B 1 North No 9 C 1 East No 10 C 2 West Yes How can I find what percentage of each type [A, B, C, D] that belongs to each area [North, South, East, West] ? Desired output: North South East West A 0.66 0.33 0 0 B 0.5 0.5 0 0 C 0 0.5 0.25 0.25 My best attempt so