You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handles the quirks of having a singular 'name' parameter for general
Index and plural 'names' parameter for MultiIndex.
"""
fromcopyimportdeepcopy
ifnamesisnotNoneandnameisnotNone:
raiseTypeError("Can only provide one of `names` and `name`")
elifnamesisNoneandnameisNone:
returndeepcopy(self.names) ifdeepelseself.names
elifnamesisnotNone:
ifnotis_list_like(names):
raiseTypeError("Must pass list-like as `names`.")
returnnames
else:
ifnotis_list_like(name):
return [name]
returnname
Moreover, it's closely tied in with copying logic without any reason, so that _validate_names() cannot be used in other cases.
I think it would be reasonable to separate these responsibilities.
The text was updated successfully, but these errors were encountered:
gfyoung
added
Indexing
Related to indexing on series/frames, not to indexes themselves
Internals
Related to non-user accessible pandas implementation
labels
Jan 12, 2018
@PoppyBagel : Thanks for reporting this! Perhaps the name is a little misleading, as you're indeed correct that we don't just validate. Maybe a name like "_parse_names" might be more appropriate. Feel free to propose another name in a PR if you like.
jbrockmendel
added
Index
Related to the Index class or subclasses
and removed
Indexing
Related to indexing on series/frames, not to indexes themselves
labels
Feb 10, 2020
Currently
Index._validate_names()
does not only validation, but some other unrelated to validation stuff:pandas/pandas/core/indexes/base.py
Lines 803 to 820 in 055bfa6
Moreover, it's closely tied in with copying logic without any reason, so that
_validate_names()
cannot be used in other cases.I think it would be reasonable to separate these responsibilities.
The text was updated successfully, but these errors were encountered: