pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.95k stars 18.04k forks source link

CLN: Refactor Index._validate_names() #19171

Open spacesphere opened 6 years ago

spacesphere commented 6 years ago

Currently Index._validate_names() does not only validation, but some other unrelated to validation stuff:

https://github.com/pandas-dev/pandas/blob/055bfa6a2a4ef81d6a0c41c6f870dbe0ec5296d3/pandas/core/indexes/base.py#L803-L820

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.

gfyoung commented 6 years ago

@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 commented 2 years ago

Probably becomes simpler once #44916 is enforced.