I am trying to convert a formula from excel to pandas.
The DataFrame looks like this:
Column A Column B
H
H
H
J
J
J
J
K
K
I want to fill column B to increment while the value in column A remains the same. In the example above, this would be:
Column A Column B
H 1
H 2
H 3
J 1
J 2
J 3
J 4
K 1
K 2
In excel, the formula would be =IF(A2<>A1,1,B1+1)
How can I apply this formula in pandas?
See Question&Answers more detail:os