-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: .unique() on MultiIndex: preserve names #20571
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
Conversation
pandas/tests/indexes/test_multi.py
Outdated
tm.assert_index_equal(res, exp) | ||
|
||
# GH #20568 - empty MI | ||
mi = pd.MultiIndex.from_arrays([[], []], names=['first', 'second']) |
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.
can u add a test w/o names as well
Codecov Report
@@ Coverage Diff @@
## master #20571 +/- ##
==========================================
- Coverage 91.84% 91.82% -0.03%
==========================================
Files 152 152
Lines 49270 49269 -1
==========================================
- Hits 45252 45239 -13
- Misses 4018 4030 +12
Continue to review full report at Codecov.
|
@jreback ready to merge if there are no further comments |
@@ -2483,6 +2493,11 @@ def test_unique_level(self, level): | |||
expected = mi.get_level_values(level) | |||
tm.assert_index_equal(result, expected) | |||
|
|||
# With empty MI | |||
mi = pd.MultiIndex.from_arrays([[], []], names=['first', 'second']) | |||
result = mi.unique(level=level) |
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.
does this also solve the case where no level is specified?
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.
No, the previous test does.
lgtm. merge away @toobaz |
git diff upstream/master -u -- "*.py" | flake8 --diff