iode.Sample.index

Sample.index(period: str | Period) int[source]

Position of the ‘period’ in the sample.

Returns:
int
Raises:
IndexError

If the ‘period’ has not been found in the sample.

Examples

>>> from iode import variables, SAMPLE_DATA_DIR
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
Loading .../fun.var
394 objects loaded
>>> variables.sample.index("1982Y1")
22
>>> variables.sample.index("2020Y1")
Traceback (most recent call last):
... 
IndexError: The period '2020Y1' is not in the sample '1960Y1:2015Y1'