pandas.timedelta_range(start=None, end=None, periods=None, freq='D', name=None, closed=None)[source]

Return a fixed frequency TimedeltaIndex, with day as the default frequency


start : string or timedelta-like, default None

Left bound for generating timedeltas

end : string or timedelta-like, default None

Right bound for generating timedeltas

periods : integer, default None

Number of periods to generate

freq : string or DateOffset, default ‘D’ (calendar daily)

Frequency strings can have multiples, e.g. ‘5H’

name : string, default None

Name of the resulting TimedeltaIndex

closed : string, default None

Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None)


rng : TimedeltaIndex


Of the three parameters: start, end, and periods, exactly two must be specified.

To learn more about the frequency strings, please see this link.


>>> pd.timedelta_range(start='1 day', periods=4)
TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'],
               dtype='timedelta64[ns]', freq='D')

The closed parameter specifies which endpoint is included. The default behavior is to include both endpoints.

>>> pd.timedelta_range(start='1 day', periods=4, closed='right')
TimedeltaIndex(['2 days', '3 days', '4 days'],
               dtype='timedelta64[ns]', freq='D')

The freq parameter specifies the frequency of the TimedeltaIndex. Only fixed frequencies can be passed, non-fixed frequencies such as ‘M’ (month end) will raise.

>>> pd.timedelta_range(start='1 day', end='2 days', freq='6H')
TimedeltaIndex(['1 days 00:00:00', '1 days 06:00:00', '1 days 12:00:00',
                '1 days 18:00:00', '2 days 00:00:00'],
               dtype='timedelta64[ns]', freq='6H')
Scroll To Top