pandas.to_timedelta

pandas 3.1.1 · General functions · function

Parse durations into timedelta values. Specify unit for numeric durations.

Call syntax

pd.to_timedelta(arg, unit=None, errors='raise')

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
arg Required
Positional or keyword
str, timedelta, list-like or Series
unit Optional
Positional or keyword
Default None
str

Specify the time unit represented by each number or required by the result.

errors Optional
Positional or keyword
Default 'raise'
{'raise', 'coerce'}

Choose how to handle invalid input or failed operations. The available options depend on the API.

Returns

timedelta