rdtools.normalization.interpolate
- rdtools.normalization.interpolate(time_series, target, max_timedelta=None, warning_threshold=0.1)
Returns an interpolation of time_series, excluding times associated with gaps in each column of time_series longer than max_timedelta; NaNs are returned within those gaps.
- Parameters:
time_series (pandas.Series, pandas.DataFrame) -- Original values to be used in generating the interpolation
target (pandas.DatetimeIndex, pandas.tseries.offsets.DateOffset, frequency string) --
If DatetimeIndex: the index onto which the interpolation is to be made
If DateOffset or frequency string: the frequency at which to resample and interpolate
max_timedelta (pandas.Timedelta, default None) -- The maximum allowed gap between values in
time_series
. Times associated with gaps longer thanmax_timedelta
are excluded from the output. If omitted,max_timedelta
is set internally to two times the median time delta intime_series
.warning_threshold (float, default 0.1) -- The fraction of data exclusion above which a warning is raised. With the default value of 0.1, a warning will be raised if the fraction of data excluded because of data gaps longer than
max_timedelta
is above than 10%.
- Return type:
pandas.Series or pandas.DataFrame (matching type of time_series) with DatetimeIndex
Note
Timezone information in the DatetimeIndexes is handled automatically, however both
time_series
andtarget
should be time zone aware or they should both be time zone naive.