I am trying to count the number of True and False values in a pandas df like this. However, I'm having trouble first using groupby() to isolate my groups before using count().
Here's a toy example of my df in which A, B, and C are columns:
A B C
1 a true
1 a true
1 b true
1 b false
2 c false
2 c true
2 c true
2 d false
Does anyone have help? Here's my desired output:
B true false
a 2 0
b 1 1
c 1 2
d 0 1
I'm new to coding in python, so many thanks in advance!