iode.Variables.periods_subset
- Variables.periods_subset(from_period: str | Period = None, to_period: str | Period = None, as_float: bool = False) List[str | float][source]
Return a subset of the periods from the current Variables sample.
- Parameters:
- from_period: str or Period, optional
first period of the subset of periods. Defaults to the first period of the current Variables sample.
- to_period: str or Period, optional
last period of the subset of periods. Defaults to the last period of the current Variables sample.
- as_float: bool, optional
whether or not to return periods as float. Defaults to False.
- Returns:
- list(str) or list(float)
Examples
>>> from iode import SAMPLE_DATA_DIR >>> from iode import variables >>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var") Loading .../fun.var 394 objects loaded >>> variables.sample Sample("1960Y1:2015Y1") >>> variables.periods_subset("1990Y1", "2000Y1") ['1990Y1', '1991Y1', ..., '1999Y1', '2000Y1'] >>> variables.periods_subset("1990Y1", "2000Y1", as_float=True) [1990.0, 1991.0, ..., 1999.0, 2000.0]