Skip to content

DOC: date_range/timedelta_range confusing 3 out of 4 arguments note #62161

@loicdiridollou

Description

@loicdiridollou

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.date_range.html#pandas.date_range
https://pandas.pydata.org/docs/dev/reference/api/pandas.timedelta_range.html

Documentation problem

We are trying to improve the type hinting for those two functions in pandas-stubs repo.
Currently the note in both those functions mentions that we should specify 3 out of 4 arguments among start, end, period, freq.
However it seems like the usage (even in the examples) one can specify only 2 of the arguments like start and end. After looking at the code, it seems like freq even if none gets converted to D.

Suggested fix for documentation

I believe we should specify two out of three start, end, periods and never all four together. Rephrasing from three out of four but if freq is omitted then ... would help clarify the goal.

Here would be a possible version:

Of the four parameters start, end, periods, and freq, between two and three must be specified. If freq is omitted,
 the resulting TimedeltaIndex will have periods linearly spaced elements between start and end (closed on both
 sides) using a day increment.

Metadata

Metadata

Assignees

Labels

DocsNeeds TriageIssue that has not been reviewed by a pandas team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions