pandas.Series.dt.to_pytimedelta
-
Series.dt.to_pytimedelta()
[source] -
Return an array of native
datetime.timedelta
objects.Python’s standard
datetime
library uses a different representation timedelta’s. This method converts a Series of pandas Timedeltas todatetime.timedelta
format with the same length as the original Series.Returns: a : numpy.ndarray
1D array containing data with
datetime.timedelta
type.See also
Examples
>>> s = pd.Series(pd.to_timedelta(np.arange(5), unit='d')) >>> s 0 0 days 1 1 days 2 2 days 3 3 days 4 4 days dtype: timedelta64[ns]
>>> s.dt.to_pytimedelta() array([datetime.timedelta(0), datetime.timedelta(1), datetime.timedelta(2), datetime.timedelta(3), datetime.timedelta(4)], dtype=object)
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Series.dt.to_pytimedelta.html