pandas.TimedeltaIndex.to_pytimedelta#

TimedeltaIndex.to_pytimedelta()[源代码]#

返回一个包含 datetime.timedelta 对象的 ndarray。

返回:
numpy.ndarray

例子

>>> tdelta_idx = pd.to_timedelta([1, 2, 3], unit="D")
>>> tdelta_idx
TimedeltaIndex(['1 days', '2 days', '3 days'],
                dtype='timedelta64[ns]', freq=None)
>>> tdelta_idx.to_pytimedelta()
array([datetime.timedelta(days=1), datetime.timedelta(days=2),
       datetime.timedelta(days=3)], dtype=object)