Use groupby in Pandas to count things in one column in comparison to another

try this:

 pd.crosstab(df.Event, df.Status)

Status  FAILED  SUCCESS
Event                  
Run          0        2
Walk         1        1


len("df.groupby('Event').Status.value_counts().unstack().fillna(0)")
61

len("df.pivot_table(index='Event', columns="Status", aggfunc=len, fill_value=0)")
74

len("pd.crosstab(df.Event, df.Status)")
32

Leave a Comment