-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: import of maybe_convert_indices in pandas.core.index.py, #10610 #10872
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
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9473a2c
Fixed import error in index.py and added exception raising for value …
169daa9
Fixed import error in index.py and added exception raising for value …
7394334
Merge remote-tracking branch 'origin/mixed_type_index' into mixed_typ…
20d4d98
Merge remote-tracking branch 'origin/mixed_type_index' into mixed_typ…
b52866a
Merge branch 'mixed_type_index' of https://github.com/djgagne/pandas …
81794cc
BUG: GH10610 Fixed import error in index.py and added exception, test
e01e5cc
Merge branch 'mixed_type_index' of https://github.com/djgagne/pandas …
a153330
BUG: #10610 Altered index checking to use existing checks to raise In…
dba2132
Merge remote-tracking branch 'upstream/master' into mixed_type_index
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 |
---|---|---|
|
@@ -1729,6 +1729,11 @@ def test_equals_op_multiindex(self): | |
df.index == index_a | ||
tm.assert_numpy_array_equal(index_a == mi3, np.array([False, False, False])) | ||
|
||
def test_multitype_list_index_access(self): | ||
df = pd.DataFrame(np.random.random((10, 5)), columns=["a"] + [20, 21, 22, 23]) | ||
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. add the issue number as a comment here |
||
with self.assertRaises(IndexError): | ||
vals = df[[22, 26, -8]] | ||
self.assertEqual(df[21].shape[0], df.shape[0]) | ||
|
||
class TestCategoricalIndex(Base, tm.TestCase): | ||
_holder = CategoricalIndex | ||
|
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.
this is already done inside
maybe_convert_indices
why do you think its needed here?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.
It is necessary because negative indices passed into maybe_convert_indices are summed by the length of the array before the bounds checking is done. Because get_indexer assigns labels that are not found in the index with a value of -1, the last row or column is assigned to those positions instead of either NaNs or an exception being raised. With the line I added, the bounds checking in maybe_convert_indices will now throw an IndexError for out of bounds indices.