I have a dataframe that consists of three columns. The last column is the 'value' which I want it to return 't' once the 'on' indicator is 1 until the 'off' indictor is switched on.
d1={'on?':[0,1,0,0,0,1,0,0,0],'off?':[0,0,0,1,0,0,0,0,0],'value':[0,1,1,0,0,1,1,1,1]} df=pd.DataFrame(d1)
The below is my desired output. I tried using the df['value']=np.where(df['on?']==1,1,0) but apparently it applies to the whole column and would not stop filling as it matches the 'off?'.
Can someone guide me through what is the best function to do a forward filling function until a certain condition is met/not met?
[