lag

lag(x, obs=1)[source]

Lag timeseries by a specified number of observations

Parameters
  • x (Series) – timeseries of prices

  • obs (int) – number of observations to lag series

Return type

Series

Returns

date-based time series of return

Usage

Shift the series backwards by a specified number of observations:

\(R_t = X_{t-obs}\)

where \(obs\) is the number of observations to lag series

Examples

Lag series by 2 observations:

>>> prices = generate_series(100)
>>> lagged = lag(prices, 2)

See also

diff()