-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix passing of numeric_only argument for categorical reduce #25304
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3678,8 +3678,12 @@ def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, | |
if axis is not None: | ||
self._get_axis_number(axis) | ||
|
||
# dispatch to ExtensionArray interface | ||
if isinstance(delegate, ExtensionArray): | ||
if isinstance(delegate, Categorical): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are u adding a code path here? the original is much more generic ; need to avoid special cases like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because Categorical deviates here from the standard ExtensionArray (see #25303 for the issue about that). If you feel strongly about it, it can indeed be handled inside Categorical. But that means that all the other arrays' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not more clear and leads to future issues There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why the others need to change at all you’re logic is circular There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would cause more changes, since the problem is actually that the argument So we could change the call for every
but then we would need to make sure every child of ExtensionArray supports this and this is currently not the case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arnov explained it well. I think we don't want to change the EA interface ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. disagree numeric_only is likely not going away anytime soon and even so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback this is not about the numeric_only in DataFrame/Series reductions that determines for which columns the reduction is calculated. This is another meaning of the keyword only for categorical that determines whether NaNs should be skipped or not. Please read #25303 So we are not speaking about removing that general use case of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i’ll look closer but am still -1 on any handling as a special case in the Series call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, to take a step back: @jreback do you agree that in the long term we can deprecate this |
||
# TODO deprecate numeric_only argument for Categorical and use | ||
# skipna as well | ||
jorisvandenbossche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return delegate._reduce(name, numeric_only=numeric_only, **kwds) | ||
elif isinstance(delegate, ExtensionArray): | ||
# dispatch to ExtensionArray interface | ||
return delegate._reduce(name, skipna=skipna, **kwds) | ||
elif is_datetime64_dtype(delegate): | ||
# use DatetimeIndex implementation to handle skipna correctly | ||
|
Uh oh!
There was an error while loading. Please reload this page.