Skip to content
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

ENH: Add numeric_only to certain groupby ops #46728

Merged
merged 16 commits into from
Apr 30, 2022

Conversation

rhshadrach
Copy link
Member

Part of #46560

For the ops that have numeric_only added, we have the option of dropping nuisance columns even when numeric_only=False is specified to be consistent with other groupby ops (e.g. sum). I decided to implement the correct behavior here instead; this required adding an argument to the cython/python paths. This argument can be removed in 2.0 when all ops would raise.

@rhshadrach rhshadrach added Enhancement Groupby Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply labels Apr 10, 2022
@rhshadrach rhshadrach marked this pull request as draft April 10, 2022 16:18
@rhshadrach rhshadrach changed the title ENH: Add numeric_only to certain groupby ops WIP/ENH: Add numeric_only to certain groupby ops Apr 10, 2022
…numeric_only_gb

� Conflicts:
�	pandas/core/frame.py
�	pandas/core/groupby/generic.py
�	pandas/core/shared_docs.py
@rhshadrach rhshadrach changed the title WIP/ENH: Add numeric_only to certain groupby ops ENH: Add numeric_only to certain groupby ops Apr 10, 2022
@rhshadrach rhshadrach marked this pull request as ready for review April 10, 2022 22:26
@rhshadrach rhshadrach marked this pull request as draft April 11, 2022 02:57
@rhshadrach rhshadrach marked this pull request as ready for review April 11, 2022 21:27
@rhshadrach rhshadrach marked this pull request as draft April 12, 2022 12:19
@rhshadrach rhshadrach marked this pull request as ready for review April 14, 2022 11:15
@rhshadrach rhshadrach added this to the 1.5 milestone Apr 15, 2022
…numeric_only_gb

� Conflicts:
�	doc/source/whatsnew/v1.5.0.rst
@rhshadrach rhshadrach requested a review from jreback April 22, 2022 01:14
@rhshadrach
Copy link
Member Author

@jreback - gentle ping.

pandas/core/groupby/groupby.py Show resolved Hide resolved
else:
nonnumeric_exclusions = frozenset()
with com.temp_setattr(
self, "exclusions", self.exclusions | nonnumeric_exclusions
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the purpose here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks - I was able to remove this hack by setting the appropriate value of raise_on_typeerror.

@jreback jreback merged commit 4a072fa into pandas-dev:main Apr 30, 2022
@jreback
Copy link
Contributor

jreback commented Apr 30, 2022

thanks @rhshadrach very nice!

@rhshadrach rhshadrach deleted the add_numeric_only_gb branch April 30, 2022 13:46
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Groupby Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add numeric_only to groupby frame ops
3 participants