pandas.to_timedelta

pandas.to_timedelta(*args, **kwargs)

Convert argument to timedelta

Parameters:

arg : string, timedelta, array of strings (with possible NAs)

unit : unit of the arg (D,h,m,s,ms,us,ns) denote the unit, which is an integer/float number

box : boolean, default True

  • If True returns a Timedelta/TimedeltaIndex of the results
  • if False returns a np.timedelta64 or ndarray of values of dtype timedelta64[ns]

errors : {‘ignore’, ‘raise’, ‘coerce’}, default ‘raise’

  • If ‘raise’, then invalid parsing will raise an exception
  • If ‘coerce’, then invalid parsing will be set as NaT
  • If ‘ignore’, then invalid parsing will return the input
Returns:

ret : timedelta64/arrays of timedelta64 if parsing succeeded