What am I trying to do?
I am trying to upsample an inconsistent signal (of around 30hz) that consists of microsecond timestamps as an index with motion capture coordinate data to 120hz.
What have I done?
To do this I have resampled the signal into microsecond samples, given the timestamps are inconsistent this made the most sense. Then I have interpolated the signal with ffill and resampled at 120hz/8333 microseconds.
Using the following code I have achieved this:
dataset = pd.read_csv('./test.trc', delimiter="\t", skiprows=3)
dataset.index = pd.to_datetime(dataset.Time)
dataset.resample('n').interpolate().ffill().resample('8333n').asfreq()
Please see screenshots below to see the dataset at each stage of this code.
What is my question?
When calling the first resample to microseconds interpolate is required. However, all it does is produce nan values for each new resampled record (the original data is still intact as expected due to the microsecond timestamps).
The subsequent ffill interpolates/fills the nan values and is therefore required to interpolate.
Why does interpolate following the first resample only produce nan values for the additional frames/records?
And why is interpolate required, if ffill is doing the interpolation? I receive the following error when calling ffill without interpolation:
ValueError: index must be monotonic increasing or decreasing
Original dataset:
Dataset after resample interpolate to microseconds (producing nan values):
Dataset after ffill (required result from interpolation):
Dataset after resample 8333n as freq:
Any help with this matter would be greatly appreciated. If you require any additional information or the original dataset please let me know.