-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Should not raise errors in .set_names for MultiIndex with nlevels == 1 (GH21149) #21196
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
Changes from 6 commits
d0c7ebc
143566a
dd60b4e
d4d2db3
46a714d
6ce4b1f
da6d530
6f65c99
44c980d
20fb292
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,18 @@ def test_set_name_methods(self): | |
assert res is None | ||
assert ind.names == new_names2 | ||
|
||
def test_multiindex_set_names(self): | ||
# GH 21149 | ||
'''Ensure that .set_names for MultiIndex with | ||
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. use triple-double quotes 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. done |
||
nlevels == 1 does not raise any errors | ||
''' | ||
result = pd.MultiIndex.from_product([[0, 1]]) | ||
result.set_names('first', level=0, inplace=True) | ||
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. test both inplace=True and False with a parameterized test 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. done |
||
expected = pd.MultiIndex(levels=[[0, 1]], | ||
labels=[[0, 1]], | ||
names=['first']) | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_set_levels_labels_directly(self): | ||
# setting levels/labels directly raises AttributeError | ||
|
||
|
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.
just say
nlevels == 1
(in double backticks)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.
Thanks - done