Skip to content

CLN: avoid try/except in Index methods #37990

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 1 commit into from
Nov 23, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

Comment on lines +2493 to +2494
if dropna and not isinstance(self, ABCMultiIndex):
# isna not defined for MultiIndex
Copy link
Member

Choose a reason for hiding this comment

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

It is reasonable to consider that ABCMultiIndex is never going to have isna defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

This came up on a dev call earlier this year and it didn't sound like there was reason for optimism.

Copy link
Contributor

Choose a reason for hiding this comment

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

isna is tricky because a MI can be multi-valued e.g does isna refer to any value on a level, or all levels be null? it would be reasonable to actually return a multi-value here (e.g. same shape as the MI), but would need to see the implications if this is done.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

some followon suggestions

Comment on lines +2493 to +2494
if dropna and not isinstance(self, ABCMultiIndex):
# isna not defined for MultiIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

isna is tricky because a MI can be multi-valued e.g does isna refer to any value on a level, or all levels be null? it would be reasonable to actually return a multi-value here (e.g. same shape as the MI), but would need to see the implications if this is done.

@@ -313,23 +308,23 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
return self._na_value

i8 = self.asi8
try:

if len(i8) and self.is_monotonic:
Copy link
Contributor

Choose a reason for hiding this comment

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

prob can de-duplicate this with min

@jreback jreback added Clean Indexing Related to indexing on series/frames, not to indexes themselves labels Nov 23, 2020
@jreback jreback added this to the 1.2 milestone Nov 23, 2020
@jreback jreback merged commit fa0e405 into pandas-dev:master Nov 23, 2020
@jbrockmendel jbrockmendel deleted the cln-trys branch November 23, 2020 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants