Apr-06-2019, 03:45 PM
Thanks for the reply. I have googled it and found the rolling window although taking the .mean(), .sum() or .min() it is not what I want.
I would like to take the data set back from each rolling window. This will be representing data sets sampling that started at a random starting point.
What I also did was to write the code myself that select indexes and gets the data. It was not so easy since I am quite new but I managed to do it. It works with data periods as well.
I share the code as well and I hope it might help someone in the future.
What I miss now is how the parts of the data sets that I pick to save on a column of a new data frame and also name that column with a sequence number.
I highlight in bold below in my code the part where the data needs to be a new column in a data set. Can you help me with that?
Thanks
Alex
Code:
I would like to take the data set back from each rolling window. This will be representing data sets sampling that started at a random starting point.
What I also did was to write the code myself that select indexes and gets the data. It was not so easy since I am quite new but I managed to do it. It works with data periods as well.
I share the code as well and I hope it might help someone in the future.
What I miss now is how the parts of the data sets that I pick to save on a column of a new data frame and also name that column with a sequence number.
I highlight in bold below in my code the part where the data needs to be a new column in a data set. Can you help me with that?
Thanks
Alex
Code:
# There are two variable important. WindowsDuration (Duration of collected measurements # and step, how many milliseconds the next window should shift. The step variable allow the picked # datasets to overlap # set the duration of the window. For example 15 seconds to pick measurements # Unit should be set in milliseconds windowDuration=500 # Unit should be in milliseconds # Next Data Collected will be starting 100ms later than the previous one step=3000 #Initial values # start is the time start of the specific window # end where window ends # these two values will be shifting by step start=data_test.index[0] end=data_test.index[0]+pd.Timedelta(milliseconds=windowDuration) while start<data_test.index[-1]: date_mask=(data_test.index > start) & (data_test.index < end) dates = data_test.index[date_mask] print(data_test.loc[dates]) # This line picks the data.I want to store that in a new separate column. Also name the column print(start) print(end) start=start+pd.Timedelta(milliseconds=step) end=end+pd.Timedelta(milliseconds=step)