-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Clarify error message when reindexing fails (#42000) #42007
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
aberres
commented
Jun 14, 2021
•
edited
Loading
edited
- closes ENH: Clarify error message when reindexing on an axis containing duplicates #42000
- Ensure all linting tests pass, see here for how to run them
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.
lgtm
pandas/core/indexes/base.py
Outdated
@@ -3708,7 +3708,7 @@ def _validate_can_reindex(self, indexer: np.ndarray) -> None: | |||
""" | |||
# trying to reindex on an axis with duplicates | |||
if not self._index_as_unique and len(indexer): | |||
raise ValueError("cannot reindex from a duplicate axis") | |||
raise ValueError("Cannot reindex on an axis with duplicate 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.
I think it's common practice not to use capitalization
SyntaxError: invalid syntax
IndexError: list index out of range
IndentationError: unexpected indent
IndentationError: expected an indented block
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.
agree. @aberres can you update & ping on green.
pandas/core/indexes/base.py
Outdated
@@ -3708,7 +3708,7 @@ def _validate_can_reindex(self, indexer: np.ndarray) -> None: | |||
""" | |||
# trying to reindex on an axis with duplicates | |||
if not self._index_as_unique and len(indexer): | |||
raise ValueError("cannot reindex from a duplicate axis") | |||
raise ValueError("Cannot reindex on an axis with duplicate 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.
agree. @aberres can you update & ping on green.
@jreback Updated. Not green, but the failing check seems unrelated? |
should now be fixed |
i'll merge with a 1.4 milestone. but a trivial change so could backport. |
Thanks @aberres |