iode.Period

class iode.Period(period_or_year: str | int | Self, periodicity: str = 'Y', step: int = 1)[source]
Attributes:
nb_periods_per_year

Number of periods in a year according to the periodicity.

periodicity

Possible values are:

step

Position of the period in the year

year

Corresponding year of the period

Methods

difference(other)

Number of sub periods between two periods.

shift(nb_periods)

Shift the current period by a number of sub periods.

from_cython_obj

__init__(period_or_year: str | int | Self, periodicity: str = 'Y', step: int = 1) Self[source]

An IODE period is defined by a year, a periodicity and by a position in the year.

Possible values for the periodicity are:

  • Y: yearly

  • S: semestrial

  • Q: quarterly

  • M: monthly

  • W: weekly

  • D: daily

Parameters:
period_or_year: str or int

If str, it is consided as a string representing the year, the periodicity and the position of the period in the year (step). If int, it is considered as the year of the period.

periodicity: str, optional

Periodicity of the period. Possible values are ‘Y’, ‘S’, ‘Q’, ‘M’, ‘W’ and ‘D’. Default to ‘Y’ (yearly).

step: int, optional

Position of the period in the year. Default to 1.

Attributes:
year: int
periodicity: str
step: int

position in the year

Examples

>>> from iode import Period
>>> # passing a string
>>> period = Period("2000Y1")
>>> period
Period("2000Y1")
>>> # passing year, periodicity and step
>>> period = Period(2010, 'Q', 1)
>>> period
Period("2010Q1")
>>> # passing only year
>>> period = Period(2010)
>>> period
Period("2010Y1")
>>> # passing year and periodicity
>>> period = Period(2010, 'Q')
>>> period
Period("2010Q1")
>>> # copy a period
>>> period_2 = Period(period)
>>> period_2
Period("2010Q1")

Methods

__init__(period_or_year[, periodicity, step])

An IODE period is defined by a year, a periodicity and by a position in the year.

difference(other)

Number of sub periods between two periods.

from_cython_obj(obj)

shift(nb_periods)

Shift the current period by a number of sub periods.

Attributes

nb_periods_per_year

Number of periods in a year according to the periodicity.

periodicity

Possible values are:

step

Position of the period in the year

year

Corresponding year of the period