Skip to content

Remove NDFrameGroupBy Class #28835

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 4 commits into from
Oct 8, 2019

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Oct 8, 2019

Was going to do a larger refactor but this diff looks more confusing than it actually is, so figured I'd stop here for readability. All I've done in this PR is:

  • Remove NDFrameGroupBy, consolidating it's methods into DataFrameGroupBy
  • Merge NDFrameGroupBy.aggregate into DataFrameGroupBy.aggregate (the latter previously called the former)

After this I am looking to find a more logical home for the functions, as the current hierarchy isn't super clear. For example, _iterate_slices() should probably be abstract in the base GroupBy class, but right now the Series implementation is in the superclass while DataFrameGroupBy overrides that for itself. Series.pct_change is practically the same as GroupBy.pct_change, so is probably unnecessary. Will be a few more follow ups mixed in

@WillAyd WillAyd added Refactor Internal refactoring of code Groupby labels Oct 8, 2019
@pep8speaks
Copy link

pep8speaks commented Oct 8, 2019

Hello @WillAyd! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-10-08 06:05:46 UTC

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.

you know how we love large PRs!

but will look

@WillAyd
Copy link
Member Author

WillAyd commented Oct 8, 2019 via email

@jreback
Copy link
Contributor

jreback commented Oct 8, 2019

Mostly just a cut and paste of the entire class def

where is this NOT a cut-paste? can you comment on the code

Copy link
Member Author

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Comments

----------
func : function
To apply to each group. Should return True or False.
dropna : Drop groups that do not pass the filter. True by default;
Copy link
Member Author

Choose a reason for hiding this comment

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

aggregate was not a copy paste because there was a def in both classes. However, the current master for DataFrameGroupBy just calls super, so that function body was simply replaced with what was previously in NDFrameGroupBy

@@ -869,6 +869,9 @@ def _cython_transform(self, how, numeric_only=True, **kwargs):

return self._wrap_transformed_output(output, names)

def _wrap_aggregated_output(self, output, names=None):
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 func was also not a direct copy paste because it existed in both classes. What was in NDFrameGroupBy was moved to GroupBy (can ref last commit)

@WillAyd
Copy link
Member Author

WillAyd commented Oct 8, 2019

It might also be helpful to look at the commits besides the blackify one to see the only things that aren’t direct copy paste.

The initial commit is the entire cut and paste, just difficult to see that by default with git

@jreback jreback added this to the 1.0 milestone Oct 8, 2019
@jreback jreback merged commit a1b2c4b into pandas-dev:master Oct 8, 2019
@jreback
Copy link
Contributor

jreback commented Oct 8, 2019

thanks @WillAyd copy-pasting is ok here!

yeah this makes sense..

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
@WillAyd WillAyd deleted the groupby-hierarchy-cleanup branch January 16, 2020 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants