Skip to content

Commit 5e90441

Browse files
committed
Added box example and removed M and Y unit references
1 parent 2e6a20b commit 5e90441

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

pandas/core/tools/timedeltas.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
1818
"""
1919
Convert argument to timedelta.
2020
21-
Timedeltas are differences in times, expressed in difference units
22-
e.g. days, hours, minutes, seconds. This method converts an argument
21+
Timedeltas are absolute differences in times, expressed in difference
22+
units e.g. days, hours, minutes, seconds. This method converts an argument
2323
from a recognized timedelta format / value into a Timedelta type.
2424
2525
Parameters
@@ -76,21 +76,13 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
7676
TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
7777
dtype='timedelta64[ns]', freq=None)
7878
79-
For `M` and `Y` units, `1M = 30D` and 1Y = 365D:
79+
Returning an ndarray by using the 'box' keyword argument:
8080
81-
>>> pd.to_timedelta(np.arange(5), unit='M')
82-
TimedeltaIndex([ '0 days 00:00:00', '30 days 10:29:06',
83-
'60 days 20:58:12', '91 days 07:27:18',
84-
'121 days 17:56:24'],
85-
dtype='timedelta64[ns]', freq=None)
86-
>>> pd.to_timedelta(np.arange(5), unit='Y')
87-
TimedeltaIndex([ '0 days 00:00:00', '365 days 05:49:12',
88-
'730 days 11:38:24', '1095 days 17:27:36',
89-
'1460 days 23:16:48'],
90-
dtype='timedelta64[ns]', freq=None)
81+
>>> pd.to_timedelta(np.arange(5), box=False)
82+
array([0, 1, 2, 3, 4], dtype='timedelta64[ns]')
9183
9284
Add new column of dates from existing dates in a `DataFrame`
93-
using `timedelta`
85+
using `timedelta`:
9486
9587
>>> Dates = pd.to_datetime(['26/10/2018','28/10/2018', '2/11/2018'])
9688
>>> df = pd.DataFrame({'Start': Dates,'Days':[5, 10, 5]})

0 commit comments

Comments
 (0)