My dataset has this structure
A = [A1, A2, A3, A4]
B = [B1, B2, B3]
C = [C1, C2, C3, C4, C5]
I want to count the occurrences of all variables in my dataset, such as:
A1 3
A2 2
A3 1
...
C4 4
C5 5
I have tried
df.groupby(df.columns[0]).A.count()
but it only works column by column, is there any way to count occurrences for the whole dataset at once? Thank you.