I have a dataset that looks like this:
Col1 Col2 Col3
A 100 100
A 0 0
A 0 100
B 100 0
C 100 100
C 100 100
I want to count the number of rows with 100 (or any other values greater than zero) based on A B and C
which will result to this:
Col2_counts Col3_counts
A 1 2
B 1 0
C 2 2
so I can calculate the total percentage of A B C in Col2 and Col3 etc.
I tried df.groupby(['Col1', 'Col 2', 'Col3']).transform ('count'), but it doesn't give me the desired result.