Skip to content

ENH: Add numeric_only to certain groupby ops #46728

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 16 commits into from
Apr 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup
  • Loading branch information
rhshadrach committed Apr 29, 2022
commit c79c7007fcc79883c25ccfd65cce0579199d0a66
8 changes: 4 additions & 4 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,19 +2153,19 @@ def var(

return self._numba_agg_general(sliding_var, engine_kwargs, ddof)
else:
numeric_only = self._resolve_numeric_only(numeric_only)
numeric_only_bool = self._resolve_numeric_only(numeric_only)
if ddof == 1:
return self._cython_agg_general(
"var",
alt=lambda x: Series(x).var(ddof=ddof),
numeric_only=numeric_only,
ignore_failures=False,
numeric_only=numeric_only_bool,
ignore_failures=numeric_only is lib.no_default,
)
else:
func = lambda x: x.var(ddof=ddof)
with self._group_selection_context():
return self._python_agg_general(
func, raise_on_typeerror=not numeric_only
func, raise_on_typeerror=not numeric_only_bool
)

@final
Expand Down