Synchronization and re-sampling of two terms with uneven millisecond intraday data

I see in python documentation the ability to reselect and synchronize two time series. My problem is more complicated because there is no time regularity in the timer. I read three times that do not have deterministic intraday timestamps. However, in order to do most of the analyzes (covariances, correlations, etc.) in these two time series, I need them to be the same length.

In Matlab, given three time series ts1, ts2, ts3with non-deterministic intraday timestamps, I can synchronize them by saying

[ts1, ts2] = synchronize(ts1, ts2, 'union');
[ts1, ts3] = synchronize(ts1, ts3, 'union');
[ts2, ts3] = synchronize(ts2, ts3, 'union');

Note that time series are already read in the pandas DataFrame, so I need to be able to synchronize (and over-execute?) With the already created DataFrames.

+4
source share
1 answer

According to the Matlab documentation you are linked with, it looks like you want

Resample timeeries using a time vector that is a union of time vectors ts1and ts2on a time interval where the two time vectors overlap.

So, first you need to find the union of the indices of your data:

newindex = df1.index.union(df2.index)

Then you can recreate your data using this index:

df1 = df1.reindex(newindex)
df2 = df2.reindex(newindex)

: NaN (-, , Matlab), , , fillna(method='pad') , interpolate(method='time') .

+3

Source: https://habr.com/ru/post/1617141/


All Articles