Skip to content

Strange output from timedelta_range for integer start/end #8886

@shoyer

Description

@shoyer

Here I expected a TimedeltaIndex with 11 elements from 0 hours through 11 hours:

>>> pd.timedelta_range(0, 10, freq='H')
<class 'pandas.tseries.tdi.TimedeltaIndex'>
['0 days']
Length: 1, Freq: <Hour>

It appears that freq is taken to refer only to the step size, not the start/stop, and the unit defaults to ns like Timedelta itself? I think we should either:

  1. add a separate unit argument -- but this is a subtle distinction
  2. use freq to also imply the unit
  3. raise on integer input (possibly in addition to 1?)

Similarly strange and somewhat inconsistent with the above example:

>>> pd.timedelta_range(0, 10, periods=100)
ValueError: Must specify two of start, end, or periods

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions