Skip to content

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

Merged
merged 1 commit into from
Mar 14, 2020

Conversation

jbrockmendel
Copy link
Member

there's some nasty try/except logic in DataFrame._reduce. This is simplifying the code around that.

@@ -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
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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":
Copy link
Member

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.

@jreback jreback added Refactor Internal refactoring of code Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Mar 14, 2020
@jreback jreback added this to the 1.1 milestone Mar 14, 2020
@jreback jreback merged commit d8f60c3 into pandas-dev:master Mar 14, 2020
@jreback
Copy link
Contributor

jreback commented Mar 14, 2020

thanks. _reduce defiinitely needs teasing apart.

@jbrockmendel jbrockmendel deleted the cln-reduce-2 branch March 14, 2020 03:04
SeeminSyed pushed a commit to CSCD01-team01/pandas that referenced this pull request Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants