I have a dataset with an average interval of 22.xx seconds between recordings while the median interval is 21 seconds.
I tried to use the DatetimeIndex.
floor/ceil/round functions (with 20/21/22 second frequencies), but these lead to duplicated indices and I need to subsequently merge the dataframe with another one, therefore, duplicated indices have to be avoided. Dropping duplicated indices also leads to significant data loss.
I want the dataframe to use an equidistant time interval, preferably rounded to 00/20/40 seconds.
A few sample rows of the data are shown below.
2018-05-06 18:02:24 1.15e+07
2018-05-06 18:02:45 1.35e+07
2018-05-06 18:03:05 1.08e+07
...
2018-05-06 18:08:30 1.11e+07
2018-05-06 18:08:50 1.20e+07
2018-05-06 18:09:10 1.30e+07
...
Which when processed should return the following.
2018-05-06 18:02:20 1.15e+07
2018-05-06 18:02:40 1.35e+07
2018-05-06 18:03:00 1.08e+07
...
2018-05-06 18:08:20 1.11e+07
2018-05-06 18:08:40 1.20e+07
2018-05-06 18:09:00 1.30e+07
...
Rounding causes the above to have duplicated indices, while floor
and ceil
also cause duplicated indices.
Any suggestions on how to adjust the drift without losing too much data?
Thanks.