@@ -353,7 +353,7 @@ TimedeltaIndex
353
353
--------------
354
354
355
355
To generate an index with time delta, you can use either the ``TimedeltaIndex `` or
356
- the `` timedelta_range ` ` constructor.
356
+ the :func: ` timedelta_range ` constructor.
357
357
358
358
Using ``TimedeltaIndex `` you can pass string-like, ``Timedelta ``, ``timedelta ``,
359
359
or ``np.timedelta64 `` objects. Passing ``np.nan/pd.NaT/nat `` will represent missing values.
@@ -363,13 +363,44 @@ or ``np.timedelta64`` objects. Passing ``np.nan/pd.NaT/nat`` will represent miss
363
363
pd.TimedeltaIndex([' 1 days' , ' 1 days, 00:00:05' ,
364
364
np.timedelta64(2 ,' D' ), datetime.timedelta(days = 2 ,seconds = 2 )])
365
365
366
- Similarly to ``date_range ``, you can construct regular ranges of a ``TimedeltaIndex ``:
366
+ Similar to ``date_range ``, you can construct regular ranges of a ``TimedeltaIndex ``
367
+ using ``timedelta_range ``. The default frequency for ``timedelta_range `` is
368
+ calendar day:
369
+
370
+ .. ipython :: python
371
+
372
+ pd.timedelta_range(start = ' 1 days' , periods = 5 )
373
+
374
+ Various combinations of ``start ``, ``end ``, and ``periods `` can be used with
375
+ ``timedelta_range ``:
376
+
377
+ .. ipython :: python
378
+
379
+ pd.timedelta_range(start = ' 1 days' , end = ' 5 days' )
380
+
381
+ pd.timedelta_range( end = ' 10 days' , periods = 4 )
382
+
383
+ The ``freq `` parameter can passed a variety of :ref: `frequency aliases <timeseries.offset_aliases >`:
367
384
368
385
.. ipython :: python
369
386
370
- pd.timedelta_range(start = ' 1 days' , periods = 5 , freq = ' D' )
371
387
pd.timedelta_range(start = ' 1 days' , end = ' 2 days' , freq = ' 30T' )
372
388
389
+ pd.timedelta_range(start = ' 1 days' , periods = 5 , freq = ' 2D5H' )
390
+
391
+
392
+ .. versionadded :: 0.23.0
393
+
394
+ Specifying ``start ``, ``end ``, and ``periods `` will generate a range of evenly spaced
395
+ timedeltas from ``start `` to ``end `` inclusively, with ``periods `` number of elements
396
+ in the resulting ``TimedeltaIndex ``:
397
+
398
+ .. ipython :: python
399
+
400
+ pd.timedelta_range(' 0 days' , ' 4 days' , periods = 5 )
401
+
402
+ pd.timedelta_range(' 0 days' , ' 4 days' , periods = 10 )
403
+
373
404
Using the TimedeltaIndex
374
405
~~~~~~~~~~~~~~~~~~~~~~~~
375
406
0 commit comments