@@ -20,16 +20,16 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
2020 """
2121 Convert argument to timedelta.
2222
23- Timedeltas are differences in times, expressed in difference units
24- e.g. days, hours, minutes, seconds. This method converts an argument
23+ Timedeltas are absolute differences in times, expressed in difference
24+ units e.g. days, hours, minutes, seconds. This method converts an argument
2525 from a recognized timedelta format / value into a Timedelta type.
2626
2727 Parameters
2828 ----------
2929 arg : String, timedelta, list, tuple, 1-d array, or Series
3030 The argument which needs to be converted to timedelta.
31- unit : Integer or float
32- Denotes the unit (Y,M, D,h,m,s,ms,us,ns) of the arg.
31+ unit : Integer or float, default ns
32+ Denotes the unit (D,h,m,s,ms,us,ns) of the arg.
3333 box : Boolean, default True
3434 If True returns a Timedelta/TimedeltaIndex of the results.
3535 if False returns a np.timedelta64 or ndarray of values of dtype
@@ -69,8 +69,6 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
6969 TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
7070 dtype='timedelta64[ns]', freq=None)
7171
72- For `M` and `Y` units, `1M = 30D` and 1Y = 365D:
73-
7472 >>> pd.to_timedelta(np.arange(5), unit='M')
7573 TimedeltaIndex([ '0 days 00:00:00', '30 days 10:29:06',
7674 '60 days 20:58:12', '91 days 07:27:18',
@@ -82,8 +80,13 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
8280 '1460 days 23:16:48'],
8381 dtype='timedelta64[ns]', freq=None)
8482
83+ Returning an ndarray by using the 'box' keyword argument:
84+
85+ >>> pd.to_timedelta(np.arange(5), box=False)
86+ array([0, 1, 2, 3, 4], dtype='timedelta64[ns]')
87+
8588 Add new column of dates from existing dates in a `DataFrame`
86- using `timedelta`
89+ using `timedelta`:
8790
8891 >>> Dates = pd.to_datetime(['26/10/2018','28/10/2018', '2/11/2018'])
8992 >>> df = pd.DataFrame({'Start': Dates,'Days':[5, 10, 5]})
0 commit comments