Skip to content

REF: remove _convert_scalar_indexer #31962

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

Merged
merged 17 commits into from
Mar 3, 2020

Conversation

jbrockmendel
Copy link
Member

This sits on top of #31867, so is partially a demonstration of how much complication is caused by our inconsistent error-raising.

@simonjayhawkins
Copy link
Member

@jbrockmendel can you merge master

@simonjayhawkins
Copy link
Member

xref #25996

@simonjayhawkins simonjayhawkins added Error Reporting Incorrect or improved errors from pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Feb 13, 2020
@WillAyd
Copy link
Member

WillAyd commented Feb 14, 2020

Definitely simplifies things so +1 there. Does this need to get bundled with the other PR to comprehensively raise a KeyError? Again on board, just want to be careful of messaging and backwards compat for users that previously caught TypeError (if even an issue - maybe they always caught both?)

@jbrockmendel
Copy link
Member Author

Does this need to get bundled with the other PR to comprehensively raise a KeyError?

Yes.

@jbrockmendel
Copy link
Member Author

closing to clear the queue, will re-open following #31867.

@jbrockmendel jbrockmendel reopened this Feb 28, 2020
@jbrockmendel
Copy link
Member Author

re-opened following #31867

@simonjayhawkins simonjayhawkins changed the title REF: remove _maybe_cast_indexer REF: remove _convert_scalar_indexer Mar 2, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Mar 2, 2020
if key_is_scalar:
key = self.index._convert_scalar_indexer(key, kind="getitem")
elif isinstance(key, (list, tuple)):
if not key_is_scalar and isinstance(key, (list, tuple)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the not key_is_scalar and is there some overlap with the check in L872-875

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove the redundant part of the check; will hold off on more invasive refactor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably no need then if refactoring later. I guess this is more performant at the expense of clarity. This method looks like it just needs one if key_is_scalar and an else.

@jreback
Copy link
Contributor

jreback commented Mar 3, 2020

love it. if you can rebase (not sure if it was before). merge on green.

@simonjayhawkins simonjayhawkins merged commit d206479 into pandas-dev:master Mar 3, 2020
@simonjayhawkins
Copy link
Member

Thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants