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 interpolationtarget (
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
, defaultNone
) -- The maximum allowed gap between values intime_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
, default0.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 thanmax_timedelta
is above than 10%.
- Returns
- 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.