woom.util.WoomDate.as_unit

woom.util.WoomDate.as_unit#

WoomDate.as_unit(unit, round_ok=True)#

Convert the underlying int64 representaton to the given unit.

Parameters:
  • unit ({"ns", "us", "ms", "s"})

  • round_ok (bool, default True) – If False and the conversion requires rounding, raise.

Return type:

Timestamp

Examples

>>> ts = pd.Timestamp('2023-01-01 00:00:00.01')
>>> ts
Timestamp('2023-01-01 00:00:00.010000')
>>> ts.unit
'ms'
>>> ts = ts.as_unit('s')
>>> ts
Timestamp('2023-01-01 00:00:00')
>>> ts.unit
's'