-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: put all post-processing at end of DataFrame._reduce #32671
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
@@ -7808,6 +7808,8 @@ def _reduce( | |||
self, op, name, axis=0, skipna=True, numeric_only=None, filter_type=None, **kwds | |||
): | |||
|
|||
assert filter_type is None or filter_type == "bool", filter_type |
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.
does it make sense to add type annotation to filter_type as well? and maybe start a docstring.
also the NotImplementedError in _get_data is now unreachable?
also out_dtype = "bool" if filter_type == "bool" else None
on L7864 is redundant?
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.
filter_type is only passed for "any" and "all", id lean towards getting rid of the kwarg altogether
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.
also the NotImplementedError in _get_data is now unreachable?
that has always been the case, but im happy to get rid of that branch altogether
@@ -7835,7 +7837,7 @@ def f(x): | |||
return op(x, axis=axis, skipna=skipna, **kwds) | |||
|
|||
def _get_data(axis_matters): | |||
if filter_type is None or filter_type == "numeric": |
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.
would it be clearer to have "numeric" as the default value of filter_type instead of None. Again maybe a docstring would help.
thanks. _reduce defiinitely needs teasing apart. |
there's some nasty try/except logic in DataFrame._reduce. This is simplifying the code around that.