pandas.Series.dt.unit#

Series.dt.unit[source]#

The precision unit of the datetime or timedelta data.

Returns the precision unit for the dtype. It means the smallest time frame that can be stored within this dtype.

Returns:
str

Unit string representation (e.g. “ns”).

See also

Series.dt.as_unit

Converts to a specific unit.

Examples

>>> ser = pd.Series(pd.to_datetime(["2020-01-02 01:02:03.004005006"]))
>>> ser.dt.unit
'ns'
>>> ser.dt.as_unit("s").dt.unit
's'