-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH add level argument to set_names, set_levels and set_labels (GH7792) #7874
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
@@ -1509,15 +1511,30 @@ def test_set_names_and_rename(self): | |||
self.assertIsNone(res) | |||
self.assertEqual(ind.names, new_names2) | |||
|
|||
def test_set_levels_and_set_labels(self): | |||
# set names for specific level | |||
ind = self.index.set_names(new_names[0], level=0) |
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.
pls add the issue reference 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.
Sorry it is my first PR. Are you expecting a reference to GH7792 as a comment in the code or in the commit message?
If you are specifically talking about the apparent removal of the test test_set_levels_and_set_labels()
, the reason it that the test became too long so I split it into two: test_set_levels()
and test_set_labels()
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.
hah...pretty good for your first PR! yes I mean just put in a comment (and the commit), the issue reference.
…_labels() (GH7792)
Added tests for the reverse (len(levels) == 2 but level =1) |
# side note - you probably wouldn't want to use levels and labels | ||
# directly like this - but it is possible. | ||
levels, labels = self.index.levels, self.index.labels | ||
new_levels = [[lev + 'a' for lev in level] for level in levels] | ||
major_labels, minor_labels = labels |
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.
did these do something
nvm, I see you just moved them
look good |
thanks! this is a nice enhancement |
Closes #7792
New
level
argument:e.g.
set_names('foo',level=1)
set_names(['foo','bar'],level=[1,2])
set_levels(['a','b','c'],level=1)
set_levels([['a','b','c'],[1,2,3]],level=[1,2])