I have a similar question to this one.
I have a dataframe with an ID column and a counter column for this idea which looks like this:
ID counter valueA   valueB
A   1       10        1
A   2       10        1
A   3       5         1
B   1       1         2
B   2       1         3
B   3       2         4
B   4       3         4
...
How can i count the row changes per column with a 1 in the dataframe, so that the dataframe looks like:
ID counter valueA   valueB
A   1       0         0
A   2       0         0
A   3       1         0
B   1       0         0
B   2       0         1
B   3       1         1
B   4       1         1
...
So that everytime a value change in the columns (only if it is the same ID, the counter should not be marked) I got a marker with 1. Note that I have more value columns, this two are only an example.
 
    