pandas icon indicating copy to clipboard operation
pandas copied to clipboard

TYP/DOC: date_range (and other *_range) functions support timedelta as freq parameter

Open ojdo opened this issue 3 years ago • 2 comments

I'm coming from a question in pandas-dev/pandas-stubs#223 asking about where mypy complains about me using a timedelta as a "freq" argument to function pandas.date_range:

Argument "freq" to "date_range" has incompatible type "timedelta"; expected "Union[str, BaseOffset]"

Since #6307 this is officially supported in at least for date_range, but very probably for most other range functions.

From what I learned over in pandas-stubs, this repo's code (or rather docstrings) should explicitly document the new type support so that pandas-stubs may infer that for their stubs.

ojdo avatar Sep 08 '22 10:09 ojdo

@ojdo I'm coming from that issue as well. Perhaps worth a PR to update the docs here?

https://github.com/pandas-dev/pandas/blob/a712c5019dc0cfb58652ddcdf06361244f38ad9f/pandas/core/indexes/datetimes.py#L969-L972

https://github.com/pandas-dev/pandas/blob/a712c5019dc0cfb58652ddcdf06361244f38ad9f/pandas/core/indexes/datetimes.py#L1166-L1167

gandhis1 avatar Sep 17 '22 19:09 gandhis1

This issue can be closed, PR was merged.

gandhis1 avatar Sep 20 '22 23:09 gandhis1