df.groupby(['Month']).agg({'Status' : ['count']})
The line above groups the dataframe by Month
and counts the number of Status
for each month. Is there a way to only get a count where Status=X
? Something like the incorrect code below:
df.groupby(['Month']).agg({'Status' == 'X' : ['count']})
Essentially, I want a count of how many Status
are X
for each month.
.filter
method. I can't comment much without the sample data – Keenankeene.apply
to do what you want. – Keenankeene