-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: x in MultiIndex.drop(x) #19054
Merged
jreback
merged 10 commits into
pandas-dev:master
from
databasedav:x-in-MultiIndex-drop-x
Jan 10, 2018
Merged
BUG: x in MultiIndex.drop(x) #19054
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
129b286
BUG: x in MultiIndex.drop(x)
9aec9de
fixing stack and typeerror checks
35ee8f0
added test
698853f
made fixes, added additional test
5da9830
updated failing test based on new behavior
a0495a4
Merge updated 'master' into x-in-MultiIndex-drop-x
552392f
add/fix comments and fix merge conflict
22d3f69
Merge branch 'master' into PR_TOOL_MERGE_PR_19054
jreback 9b79e96
remove redundant dropped columns conditional
a516fcc
Merge origin branch.
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 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 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 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 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 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 |
---|---|---|
|
@@ -705,6 +705,26 @@ def test_multiindex_symmetric_difference(self): | |
result = idx ^ idx2 | ||
assert result.names == [None, None] | ||
|
||
def test_multiindex_contains_dropped(self): | ||
# GH 19027 | ||
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. can you add a comment |
||
# test that dropped MultiIndex levels are not in the MultiIndex | ||
# despite continuing to be in the MultiIndex's levels | ||
idx = MultiIndex.from_product([[1, 2], [3, 4]]) | ||
assert 2 in idx | ||
idx = idx.drop(2) | ||
|
||
# drop implementation keeps 2 in the levels | ||
assert 2 in idx.levels[0] | ||
# but it should no longer be in the index itself | ||
assert 2 not in idx | ||
|
||
# also applies to strings | ||
idx = MultiIndex.from_product([['a', 'b'], ['c', 'd']]) | ||
assert 'a' in idx | ||
idx = idx.drop('a') | ||
assert 'a' in idx.levels[0] | ||
assert 'a' not in idx | ||
|
||
|
||
class TestMultiIndexSlicers(object): | ||
|
||
|
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.
what test exercises this?
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.
pandas/pandas/tests/test_multilevel.py
Line 1195 in 35b2aba
pandas/pandas/tests/frame/test_reshape.py
Line 136 in 35b2aba
pandas/pandas/tests/frame/test_reshape.py
Line 730 in 35b2aba
These were the 3. And it looks like Travis doesn't have permalinks to specific lines like GitHub?
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 just took a look at the test that caused most of the builds to fail:
pandas/pandas/tests/frame/test_mutate_columns.py
Lines 186 to 198 in 35b2aba
and we just changed this so I'll go ahead and negate the
assert
.