I have a table with two columns. In the second column is binary, 0 or 1 value. I would like to keep a running count of these values until it switches. For example, i would like to add a 'count' column that looks like this:
Date sig count
2000-01-03 0 1
2000-01-04 0 2
2000-01-05 1 1
2000-01-06 1 2
2000-01-07 1 3
2000-01-08 1 4
2000-01-09 0 1
2000-01-010 0 2
2000-01-011 0 3
2000-01-012 0 4
2000-01-013 0 5
Is there a simple way of doing this with pandas, numpy or simply python without having to iterate or use loops?