modin.pandas.DatetimeIndex.as_unit

DatetimeIndex.as_unit(unit: str) DatetimeIndex[source]

Convert to a dtype with the given unit resolution.

Parameters:

unit ({'s', 'ms', 'us', 'ns'}) –

Return type:

same type as self

Examples

>>> idx = pd.DatetimeIndex(['2020-01-02 01:02:03.004005006'])
>>> idx
DatetimeIndex(['2020-01-02 01:02:03.004005006'], dtype='datetime64[ns]', freq=None)
>>> idx.as_unit('s')  
DatetimeIndex(['2020-01-02 01:02:03'], dtype='datetime64[s]', freq=None)
Copy