I am looking for a solution to changing row values until a particular row is appeared.
For example, here is a dataframe
df = pd.DataFrame({'ts_val' : [0,0,-1,-1,-1,-1,0,0,0,0,0],
'on&off' : [0,0,1,0,0,0,1,0,1,0,1]
})
Out[11] df
ts_val on&off
0 0 0
1 0 0
2 -1 1 #starting point
3 -1 0
4 -1 0
5 -1 0
6 0 1 #end point
7 0 0
8 0 1 #starting point 2
9 0 0
10 0 1 #end point 2
On above dataframe, I want to replace row of df['on&off'] as 1 untill another 1 is appeared on the df['on&off']
In more detail, on the example, 1 is appeared on df['on&off'][2] which is a starting point, and another 1 which is end point is appeared on the df['on&off'][6]. I need to replace the value to 1 between df['on&off'][2:6].
Such as, this dataframe :
ts_val on&off
0 0 0
1 0 0
2 -1 1
3 -1 1
4 -1 1
5 -1 1
6 0 1
7 0 0
8 0 1
9 0 1
10 0 1
