I need to create a new series on my pandas DataFrame to count the number of switch of another value. Here an example:
I need a function to calculate the column new_counter
. The DataFrame is sorted by foo
and date
. The counter increases when the variable foo
or the variable baz
change.