I have the following df:
Doc Item
1 1
1 1
1 2
1 3
2 1
2 2
I want to add third column with repeating values that (1) increment by one if there is a change in column "Item" and that also (2) restarts if there is a change in column "Doc"
Doc Item NewCol
1 1 1
1 1 1
1 2 2
1 3 3
2 1 1
2 2 2
What is the best way to achieve this? Thanks a lot.
pd.read_clipboardunless it's MulitIndex or having datetime