Suppose there is an information sheet of a group of students , They are from 1,2,3,4,5 A class , Now I want to calculate the number of boys and girls in each class respectively
If the group is normal, I know it can df.groupby('calss')['gender'].value_counts()
But now I want to get the number of boys and girls in each class respectively list, How to write
All I can think of is df.loc[df.gender==' male ']groupby('class')['gender'].value_counts() such , Is there any other way