I have 2 time series data frames. Both contain values [0,1] only. The first one is called init_signal and the second is called end_signal. The idea is to create a new dataframe when init_signal has a 1, it will find the NEXT 1 in end_signal.
Example below merges both the init_signal and end_signal as one dataframe. the first column is init_signal and the second column is end_signal.
For example:
2016-06-13 1 0
2016-06-14 0 0
2016-06-15 0 1
2016-06-16 0 0
Will become:
2016-06-13 1
2016-06-14 1
2016-06-15 1
2016-06-16 0
For example 2:
2016-06-13 1 1
2016-06-14 0 0
2016-06-15 0 1
2016-06-16 0 0
Will become:
2016-06-13 1
2016-06-14 1
2016-06-15 1
2016-06-16 0
In the 2nd example, if there is also a 1 in the same row as the init_signal, it will be ignored.
I've been using a complex loop. Is there a non-looping way?
from Python Setting Values Given Two Column
No comments:
Post a Comment