Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ojdo opened this issue Sep 8, 2022 · 2 comments
Labels
Docs Timedelta Timedelta data type Typing type annotations, mypy/pyright type checking

Comments

@ojdo
Copy link
Contributor

ojdo commented Sep 8, 2022

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 ojdo changed the title TYP/DOC: document timedelta in date_range (and possibly most other *_range) functions TYP/DOC: date_range (and other *_range) functions support timedelta as freq parameter Sep 8, 2022
@datapythonista datapythonista added Docs Timedelta Timedelta data type Typing type annotations, mypy/pyright type checking labels Sep 8, 2022
@gandhis1
Copy link
Contributor

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

freq : str or DateOffset, default 'D'
Frequency strings can have multiples, e.g. '5H'. See
:ref:`here <timeseries.offset_aliases>` for a list of
frequency aliases.

freq : str or DateOffset, default 'B' (business daily)
Frequency strings can have multiples, e.g. '5H'.

@gandhis1
Copy link
Contributor

This issue can be closed, PR was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Timedelta Timedelta data type Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

No branches or pull requests

4 participants