Normalise lag specifications into a sorted numpy array of non-negative integers.
Parameters
Name
Type
Description
Default
lags
(str, int, Sequence[int], range, slice)
- String durations (e.g. "30 days", "3 months") are converted to the number of observation lags implied by index. - Integers produce a range(0, lags) style sequence (inclusive). - Sequences/ranges/slices are materialised and sorted.
required
index
array - like
A date/time index used to translate duration strings into row counts. The index is sorted internally.
required
clamp
bool
If True (default), lags greater than len(index) - 1 are clipped.
True
Returns
Name
Type
Description
np.ndarray
Sorted array of lag integers starting at zero.
Raises
Name
Type
Description
ValueError
When the input cannot be interpreted or the index is empty.
Examples
import numpy as npimport pandas as pdimport pytimetk as tkidx = pd.date_range("2020-01-01", periods=5, freq="D")tk.resolve_lag_sequence("3 days", idx)