DateTimeIndex¶
Initializes a DateTimeIndex with the given index.
Parameters¶
- indexnp.ndarray
Index array.
Examples¶
>>> idx = DateTimeIndex(np.array(['2022-01-01', '2022-01-02', '2022-01-03'], dtype='datetime64'))
>>> idx.keys
array(['2022-01-01T00:00:00.000000000', '2022-01-02T00:00:00.000000000',
'2022-01-03T00:00:00.000000000'], dtype='datetime64[ns]')
- Sloth.DateTimeIndex.get_item()¶
Retrieves the exact index location of the given argument.
- Parameters:
- argnp.datetime64 or int
The key to retrieve the index for.
- Returns:
- int
The index of the key.
Examples
>>> idx = DateTimeIndex(np.array(['2022-01-01', '2022-01-02', '2022-01-03'], dtype='datetime64')) >>> idx.get_item(np.datetime64('2022-01-02')) 1
- Sloth.DateTimeIndex.to_pandas()¶
Converts the DateTimeIndex to a pandas DatetimeIndex object.
- Returns:
- pd.DatetimeIndex
A pandas DatetimeIndex object.
Examples
>>> idx = DateTimeIndex(np.array(['2022-01-01', '2022-01-02', '2022-01-03'], dtype='datetime64')) >>> idx.to_pandas() DatetimeIndex(['2022-01-01', '2022-01-02', '2022-01-03'], dtype='datetime64[ns]', freq=None)