-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Conversation
if dropna and not isinstance(self, ABCMultiIndex): | ||
# isna not defined for MultiIndex |
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.
It is reasonable to consider that ABCMultiIndex
is never going to have isna
defined?
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.
This came up on a dev call earlier this year and it didn't sound like there was reason for optimism.
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.
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.
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.
some followon suggestions
if dropna and not isinstance(self, ABCMultiIndex): | ||
# isna not defined for MultiIndex |
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.
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: |
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.
prob can de-duplicate this with min
No description provided.