Similar to this Question,
Given,
I would like to find the 'Cumulative Sum Of Occurrence Master Event' , and 'Cumulative Sum Of Occurrence Event A ' and Event B in between the Master Event. In other words, the instance when Master Event Occour, Cummulative Sum of Event A is reset to Zero.
Sample output is as follows,
Sample Input code by @Jon Strutz
import pandas as pd
df = pd.DataFrame({'year': [2019] * 10,
'month': [8] * 10,
'day': [16] * 10,
'hour': [12, 12, 12, 12, 13, 13, 13, 13, 13, 13],
'minute': [50, 52, 53, 57, 0, 3,4,5,13,21]})
df = pd.DataFrame(pd.to_datetime(df), columns=['Time_Stamp'])
df['Event_Master'] = [0, 0, 1, 0, 0 ,0, 0, 0, 1,0]
df['Event_B'] = [0, 0, 0, 1, 0 ,0, 1, 0, 0,1]
And expected output could be like
df['Event_Master_Out'] = [0, 0, 1, 1, 1 ,1, 1, 1, 2,2]
df['Event_B_Out'] = [0, 0, 0, 1, 1 ,1, 2, 2, 0,1]