I have a dataframe with a dummy column that contains 1s and 0s and I would like to count for each row how many times the 1s or 0s have occurred, starting at 0 every time, and counting up for 1s and counting down for 0s I have an example below:
import pandas as pd
df = pd.DataFrame({'Dummy': [0, 0, 1, 1, 1, 0, 1, 1, 1, 1],
'Counter': [-1, -2, 1, 2, 3, -1, 1, 2, 3, 4]})