-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: date_range support reso keyword #49106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6baaa7e
ENH: date_range support reso keyword
jbrockmendel 69be870
GH ref
jbrockmendel f67d877
pyright ignore
jbrockmendel da3e5ea
Merge branch 'main' into nano-date_range
jbrockmendel 21877ae
reso->unit
jbrockmendel 4a8ed2f
raise if endpoints cant cast losslessly
jbrockmendel 6022515
Merge branch 'main' into nano-date_range
jbrockmendel 761b793
Merge branch 'main' into nano-date_range
jbrockmendel 7767339
Merge branch 'main' into nano-date_range
jbrockmendel 246038c
Merge branch 'main' into nano-date_range
jbrockmendel 6220000
add assertions
jbrockmendel efc392b
Merge branch 'main' into nano-date_range
jbrockmendel 44c43cf
mypy fixup
jbrockmendel d0b6d42
example with unit
jbrockmendel 3277a40
typo fixup
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -818,6 +818,8 @@ def date_range( | |
normalize: bool = False, | ||
name: Hashable = None, | ||
inclusive: IntervalClosedType = "both", | ||
*, | ||
unit: str | None = None, | ||
**kwargs, | ||
) -> DatetimeIndex: | ||
""" | ||
|
@@ -856,6 +858,10 @@ def date_range( | |
Include boundaries; Whether to set each bound as closed or open. | ||
|
||
.. versionadded:: 1.4.0 | ||
unit : str, default None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add an example in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated+green |
||
Specify the desired resolution of the result. | ||
|
||
.. versionadded:: 2.0.0 | ||
**kwargs | ||
For compatibility. Has no effect on the result. | ||
|
||
|
@@ -966,6 +972,14 @@ def date_range( | |
>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive='right') | ||
DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04'], | ||
dtype='datetime64[ns]', freq='D') | ||
|
||
**Specify a unit** | ||
|
||
>>> pd.date_range(start="2017-01-01", periods=10, freq="100AS", unit="s") | ||
DatetimeIndex(['2017-01-01', '2117-01-01', '2217-01-01', '2317-01-01', | ||
'2417-01-01', '2517-01-01', '2617-01-01', '2717-01-01', | ||
'2817-01-01', '2917-01-01'], | ||
dtype='datetime64[s]', freq='100AS-JAN') | ||
""" | ||
if freq is None and com.any_none(periods, start, end): | ||
freq = "D" | ||
|
@@ -978,6 +992,7 @@ def date_range( | |
tz=tz, | ||
normalize=normalize, | ||
inclusive=inclusive, | ||
unit=unit, | ||
**kwargs, | ||
) | ||
return DatetimeIndex._simple_new(dtarr, name=name) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also another reminder that in a future PR it would be good to collect all these non-nano updates and introduce them in a separate section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
planning to do this once the astype and constructor stuff is all in