0

How to count the past occurrences on every occurrence using pandas?

Given:

   A
0  x
1  y
2  z
3  x
4  x
5  y

Output:

   A  B
0  x  1
1  y  1
2  z  1
3  x  2
4  x  3
5  y  2
Teodor Scorpan
  • 868
  • 1
  • 10
  • 20

0 Answers0