Uncategorized

pandas – Python Count the occurence from 0 to the current nth row


i have a pandas dataset
A
0 a
1 c
2 b
3 b
4 a
5 c
6 b
and want to get the count at each step, the output should be this:
A Output
0 a 1
1 c 1
2 b 1
3 b 2
4 a 2
5 c 2
6 b 3

i tried using groupby count formula but its not giving me the right output



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *