iode.Period.shift

Period.shift(self, nb_periods: int) Period

Shift the current period by a number of sub periods. If the number of sub periods is positive, the shift is time forward. Conversely, if the number of sub periods is negative, the shift is time backward.

Parameters:
nb_periods: int

Number of sub periods. The shift is time forward if positive and time backward if negative.

Returns:
shifted_period: Period

Examples

>>> from iode import Period
>>> period = Period(2000, 'Q', 1)
>>> period
'2000Q1'
>>> # shift forward
>>> shifted_period = period.shift(7)
>>> shifted_period
'2001Q4'
>>> # shift backward
>>> shifted_period = period.shift(-7)
>>> shifted_period
'1998Q2'