@@ -352,8 +352,8 @@ You can convert a ``Timedelta`` to an `ISO 8601 Duration`_ string with the
352
352
TimedeltaIndex
353
353
--------------
354
354
355
- To generate an index with time delta, you can use either the `` TimedeltaIndex ` ` or
356
- the `` timedelta_range ` ` constructor.
355
+ To generate an index with time delta, you can use either the :class: ` TimedeltaIndex ` or
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,47 @@ 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
+ Generating Ranges of Time Deltas
367
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368
+
369
+ Similar to :func: `date_range `, you can construct regular ranges of a ``TimedeltaIndex ``
370
+ using :func: `timedelta_range `. The default frequency for ``timedelta_range `` is
371
+ calendar day:
372
+
373
+ .. ipython :: python
374
+
375
+ pd.timedelta_range(start = ' 1 days' , periods = 5 )
376
+
377
+ Various combinations of ``start ``, ``end ``, and ``periods `` can be used with
378
+ ``timedelta_range ``:
379
+
380
+ .. ipython :: python
381
+
382
+ pd.timedelta_range(start = ' 1 days' , end = ' 5 days' )
383
+
384
+ pd.timedelta_range(end = ' 10 days' , periods = 4 )
385
+
386
+ The ``freq `` parameter can passed a variety of :ref: `frequency aliases <timeseries.offset_aliases >`:
367
387
368
388
.. ipython :: python
369
389
370
- pd.timedelta_range(start = ' 1 days' , periods = 5 , freq = ' D' )
371
390
pd.timedelta_range(start = ' 1 days' , end = ' 2 days' , freq = ' 30T' )
372
391
392
+ pd.timedelta_range(start = ' 1 days' , periods = 5 , freq = ' 2D5H' )
393
+
394
+
395
+ .. versionadded :: 0.23.0
396
+
397
+ Specifying ``start ``, ``end ``, and ``periods `` will generate a range of evenly spaced
398
+ timedeltas from ``start `` to ``end `` inclusively, with ``periods `` number of elements
399
+ in the resulting ``TimedeltaIndex ``:
400
+
401
+ .. ipython :: python
402
+
403
+ pd.timedelta_range(' 0 days' , ' 4 days' , periods = 5 )
404
+
405
+ pd.timedelta_range(' 0 days' , ' 4 days' , periods = 10 )
406
+
373
407
Using the TimedeltaIndex
374
408
~~~~~~~~~~~~~~~~~~~~~~~~
375
409
0 commit comments