Skip to main content
`Ctrl`+`K`

# pandas.Timedelta.as_unit

Timedelta.as_unit(unit, round_ok=True)

  Convert the underlying int64 representation to the given unit.

  Parameters:
    unit{“ns”, “us”, “ms”, “s”}
    round_ok bool, default True

      If False and the conversion requires rounding, raise.

  Returns:
    Timedelta

  See also

  `Timedelta`

    Represents a duration, the difference between two dates or times.

  `to_timedelta`

    Convert argument to timedelta.

  `Timedelta.asm8`

    Return a numpy timedelta64 array scalar view.

  Examples

      >>> td = pd.Timedelta('1001ms')
      >>> td
      Timedelta('0 days 00:00:01.001000')
      >>> td.as_unit('s')
      Timedelta('0 days 00:00:01')