pandas.Timedelta.to_pytimedelta#

Timedelta.to_pytimedelta()#

Convert a pandas Timedelta object into a python datetime.timedelta object.

Timedelta objects are internally saved as numpy datetime64[ns] dtype. Use to_pytimedelta() to convert to object dtype.

Returns:
datetime.timedelta or numpy.array of datetime.timedelta

See also

to_timedelta

Convert argument to Timedelta type.

Notes

Any nanosecond resolution will be lost.

Examples

>>> td = pd.Timedelta('3D')
>>> td
Timedelta('3 days 00:00:00')
>>> td.to_pytimedelta()
datetime.timedelta(days=3)