I have a pandas dataframe that looks like this:
name | category | status |
---|---|---|
John | student | yes |
Jane | employee | no |
Elijah | student | no |
Anne | student | yes |
Elle | employee | no |
I want to count the number of each categories that have status 'yes'
I have tried 2 codes below:
(DataFrame['status'].eq('yes').groupby(DataFrame['category']).nunique())
(DataFrame['status'].eq('yes').groupby(DataFrame['category']).any().sum())
both codes give the same output:
category
student 2
employee 1
but, this is the output that I expect:
category
student 2
employee 0
can you help me fix this?