modin.pandas.DatetimeIndex.snap

DatetimeIndex.snap(freq: Frequency = 'S') DatetimeIndex[source]

Snap time stamps to nearest occurring frequency.

Return type:

DatetimeIndex

Examples

>>> idx = pd.DatetimeIndex(['2023-01-01', '2023-01-02',
...                        '2023-02-01', '2023-02-02'])
>>> idx
DatetimeIndex(['2023-01-01', '2023-01-02', '2023-02-01', '2023-02-02'], dtype='datetime64[ns]', freq=None)
>>> idx.snap('MS')  
DatetimeIndex(['2023-01-01', '2023-01-01', '2023-02-01', '2023-02-01'], dtype='datetime64[ns]', freq=None)
Copy