-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: referring to duplicate level name raises ValueError #21678
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
API: referring to duplicate level name raises ValueError #21678
Conversation
Hello @jorisvandenbossche! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on July 08, 2018 at 13:57 Hours UTC |
Changed the implementation a bit to keep the fallback logic for integer names, to decouple it from the discussion in #21677 |
Codecov Report
@@ Coverage Diff @@
## master #21678 +/- ##
=========================================
Coverage ? 91.9%
=========================================
Files ? 160
Lines ? 49894
Branches ? 0
=========================================
Hits ? 45854
Misses ? 4040
Partials ? 0
Continue to review full report at Codecov.
|
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.
wow much simpler
minor comment - pls add whatsnew note
any downsides to doing this?
pandas/core/indexes/multi.py
Outdated
@@ -755,11 +755,11 @@ def _from_elements(values, labels=None, levels=None, names=None, | |||
return MultiIndex(levels, labels, names, sortorder=sortorder) | |||
|
|||
def _get_level_number(self, level): | |||
count = self.names.count(level) | |||
if (count > 1) and not isinstance(level, int): |
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.
use is_integer here
I don't think the code is simpler, the diff is just smaller :-)
I don't think so. |
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.
minor comment
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -229,6 +229,9 @@ Other API Changes | |||
^^^^^^^^^^^^^^^^^ | |||
|
|||
- :class:`DatetimeIndex` now accepts :class:`Int64Index` arguments as epoch timestamps (:issue:`20997`) | |||
- Accessing a level of a ``MultiIndex`` with a duplicate name (e.g. in | |||
:meth:~MultiIndex.get_level_values) now raises a ValueError instead of |
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.
double backticks around the errors
follow-up on: #21423
But, this currently has a lot of failures, because of #21677 that we first need to resolve.