-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Timedelta/Timestamp round support non-nano #47356
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
5 commits
Select commit
Hold shift + click to select a range
786e8da
ENH: Timedelta/Timestamp round support non-nano
jbrockmendel 09bb5a2
Merge branch 'main' into nano-round
jbrockmendel ca6c7e2
parametrize test_floor
jbrockmendel cbe893a
Merge branch 'main' into nano-round
jbrockmendel 05fb02d
un-xfail
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,27 +148,26 @@ def test_round_minute_freq(self, test_input, freq, expected, rounder): | |
result = func(freq) | ||
assert result == expected | ||
|
||
def test_ceil(self): | ||
dt = Timestamp("20130101 09:10:11") | ||
@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"]) | ||
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 parameterize 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. good idea, updated |
||
def test_ceil(self, unit): | ||
dt = Timestamp("20130101 09:10:11")._as_unit(unit) | ||
result = dt.ceil("D") | ||
expected = Timestamp("20130102") | ||
assert result == expected | ||
assert result._reso == dt._reso | ||
|
||
def test_floor(self): | ||
dt = Timestamp("20130101 09:10:11") | ||
@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"]) | ||
def test_floor(self, unit): | ||
dt = Timestamp("20130101 09:10:11")._as_unit(unit) | ||
result = dt.floor("D") | ||
expected = Timestamp("20130101") | ||
assert result == expected | ||
assert result._reso == dt._reso | ||
|
||
@pytest.mark.parametrize("method", ["ceil", "round", "floor"]) | ||
@pytest.mark.parametrize( | ||
"unit", | ||
[ | ||
"ns", | ||
pytest.param("us", marks=pytest.mark.xfail(reason="round not implemented")), | ||
pytest.param("ms", marks=pytest.mark.xfail(reason="round not implemented")), | ||
pytest.param("s", marks=pytest.mark.xfail(reason="round not implemented")), | ||
], | ||
["ns", "us", "ms", "s"], | ||
) | ||
def test_round_dst_border_ambiguous(self, method, unit): | ||
# GH 18946 round near "fall back" DST | ||
|
@@ -203,12 +202,7 @@ def test_round_dst_border_ambiguous(self, method, unit): | |
) | ||
@pytest.mark.parametrize( | ||
"unit", | ||
[ | ||
"ns", | ||
pytest.param("us", marks=pytest.mark.xfail(reason="round not implemented")), | ||
pytest.param("ms", marks=pytest.mark.xfail(reason="round not implemented")), | ||
pytest.param("s", marks=pytest.mark.xfail(reason="round not implemented")), | ||
], | ||
["ns", "us", "ms", "s"], | ||
) | ||
def test_round_dst_border_nonexistent(self, method, ts_str, freq, unit): | ||
# GH 23324 round near "spring forward" DST | ||
|
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.
Do we have tests that trigger the raising behavior?
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.
Yes