PeriodIndex

Index containing values of time along a regular period of time.

Parameters

start: datetime-like

Starting time in a range

stop: datetime-like

End time in the range

freq: str

How often to create point. ie: ‘1h’, ‘4W’, ‘200s’

Examples

>>> idx = PeriodIndex('2022-01-01', '2022-01-10', '1d')
>>> idx.keys_
array(['2022-01-01', '2022-01-02', '2022-01-03', '2022-01-04',
       '2022-01-05', '2022-01-06', '2022-01-07', '2022-01-08',
       '2022-01-09'], dtype='datetime64[D]')
Sloth.PeriodIndex.get_item()

Retrieves an item based on its index.

Parameters:
argint

The item to retrieve.

Returns:
int

The index of the item.

Raises:
KeyError

If the item is not in the slice.

Examples

>>> idx = RangeIndex(0, 10, 2)
>>> idx.get_item(4)
2
>>> idx.get_item(5)
KeyError: '5 not in slice'
Sloth.PeriodIndex.to_pandas()

Converts the PeriodIndex to a pandas PeriodIndex object.

Returns:
pd.PeriodIndex

A pandas PeriodIndex object.

Examples

>>> idx = PeriodIndex('2022-01-01', '2022-01-10', '1d')
>>> idx.to_pandas()
PeriodIndex(['2022-01-01', '2022-01-10'], dtype='period[1d]')