I would like to see the nth occurrence of each value in a pandas series. For example I have a series as shown below:
pd.DataFrame(pd.Series(['a', 'a', 'b', 'c', 'a', 'b', 'a', 'a', 'b', 'c', 'b', 'b'], name='A'))
A
0 a
1 a
2 b
3 c
4 a
5 b
6 a
7 a
8 b
9 c
10 b
11 b
B being the occurrence count from top to bottom, I would like to see the dataframe below:
A B
0 a 1
1 a 2
2 b 1
3 c 1
4 a 3
5 b 2
6 a 4
7 a 5
8 b 3
9 c 2
10 b 4
11 b 5