-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Index.get_slice_bounds does not accept datetime.date or tz naive datetime.datetimes #35848
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
18 commits
Select commit
Hold shift + click to select a range
6d89323
Ensure dates can be passed into get_slice bounds
df11f81
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
bf6ea7e
Cast the slice bounds and conform the tz
0a9e38a
Create new test file for get_slice_bound
460284d
Move file and add tests for numeric and object types
2b06ce2
Add whatsnew
5fface8
English
93f7162
Skip typing for now
8324841
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
54cc06b
Move conversion logic to _maybe_cast_for_get_loc
a25df77
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
830df02
Split tests into relevant files, put back assertion, dont need to che…
75a9afb
lint
9c5c0f2
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
467c2e4
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
8be380a
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
5f7422e
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
ef20794
Merge remote-tracking branch 'upstream/master' into bug/get_slice_bounds
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from pandas import Index | ||
|
||
|
||
class TestGetSliceBounds: | ||
@pytest.mark.parametrize("kind", ["getitem", "loc", None]) | ||
@pytest.mark.parametrize("side, expected", [("left", 4), ("right", 5)]) | ||
def test_get_slice_bounds_within(self, kind, side, expected): | ||
index = Index(list("abcdef")) | ||
result = index.get_slice_bound("e", kind=kind, side=side) | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize("kind", ["getitem", "loc", None]) | ||
@pytest.mark.parametrize("side", ["left", "right"]) | ||
@pytest.mark.parametrize( | ||
"data, bound, expected", [(list("abcdef"), "x", 6), (list("bcdefg"), "a", 0)], | ||
) | ||
def test_get_slice_bounds_outside(self, kind, side, expected, data, bound): | ||
index = Index(data) | ||
result = index.get_slice_bound(bound, kind=kind, side=side) | ||
assert result == expected | ||
|
||
def test_get_slice_bounds_invalid_side(self): | ||
with pytest.raises(ValueError, match="Invalid value for side kwarg"): | ||
Index([]).get_slice_bound("a", kind=None, side="middle") |
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
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.
Uh oh!
There was an error while loading. Please reload this page.