iode.Sample.index

Sample.index(self, period: str | Period) int

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")
>>> 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'