iode.Period
- class iode.Period
- Attributes:
periodicityperiodicity: str
stepstep: int
yearyear: int
Methods
difference(self, other)Number of sub periods between two periods.
nb_periods_per_year(self)Number of periods in a year according to the periodicity.
shift(self, nb_periods)Shift the current period by a number of sub periods.
to_float(self)Returns a numerical representation of the period.
- __init__(self, *args: str | Tuple[int, str, int]) Period
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:
- *args: str or (int, str, int)
Either a string representing the period or values representing the year, the periodicity and the position of the period in the year (step):
- period: str
String representing the period.
or
- year: int
Year of the period.
- periodicity: {‘Y’, ‘S’, ‘Q’, ‘M’, ‘W’, ‘D’}, optional
Periodicity of the period. Default to ‘Y’ (yearly).
- step: int, optional
Position of the period in the year. Default to 1.
Examples
>>> from iode import Period >>> # passing a string >>> period = Period("2000Y1") >>> period '2000Y1' >>> # passing year, periodicity and step >>> period = Period(2010, 'Q', 1) >>> period '2010Q1' >>> # passing only year >>> period = Period(2010) >>> period '2010Y1' >>> # passing year and periodicity >>> period = Period(2010, 'Q') >>> period '2010Q1' >>> # copy a period >>> period_2 = Period(period) >>> period_2 '2010Q1'
- Attributes:
- year: int
- periodicity: str
- step: int
position in the year
Methods
__init__(self, *args)An IODE period is defined by a year, a periodicity and by a position in the year.
difference(self, other)Number of sub periods between two periods.
nb_periods_per_year(self)Number of periods in a year according to the periodicity.
shift(self, nb_periods)Shift the current period by a number of sub periods.
to_float(self)Returns a numerical representation of the period.
Attributes
periodicity: str
step: int
year: int