-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DEPR: Change numeric_only to False in various groupby ops #49892
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
DEPR: Change numeric_only to False in various groupby ops #49892
Conversation
warn = FutureWarning if func == "std" else None | ||
msg = "The default value of numeric_only" | ||
with tm.assert_produces_warning(warn, match=msg): | ||
result = df.groupby(level=1, axis=1).agg(func) |
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.
In 1.5.x we are currently warning in a few erroneous cases with axis=1. Is this worth fixing? I think the PR would have to go straight into 1.5.x because of the enforced deprecations.
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.
I would say if we haven't gotten an issue about this yet I think it's okay not fixing for now
@@ -572,7 +572,7 @@ Removal of prior version deprecations/changes | |||
- Changed default of ``numeric_only`` to ``False`` in all DataFrame methods with that argument (:issue:`46096`, :issue:`46906`) | |||
- Changed default of ``numeric_only`` to ``False`` in :meth:`Series.rank` (:issue:`47561`) | |||
- Enforced deprecation of silently dropping nuisance columns in groupby and resample operations when ``numeric_only=False`` (:issue:`41475`) | |||
- Changed default of ``numeric_only`` to ``False`` in :meth:`.DataFrameGroupBy.sum` and :meth:`.DataFrameGroupBy.mean` (:issue:`46072`) | |||
- Changed default of ``numeric_only`` to ``False`` in various :class:`.DataFrameGroupBy` methods (:issue:`46072`) |
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.
Still some ops enforce numeric_only=False, mostly those that use _op_via_apply
. Will be changing this to
The default of ``numeric_only`` is now ``False`` across all :class:`.DataFrameGroupBy` methods
once all ops are done.
does this finish off the nuisance column stuff? |
No - we still have some grouby ops (those that go through _op_via_apply) and then resampler / window. |
…rce_numeric_only_groupby_false
…rce_numeric_only_groupby_false � Conflicts: � doc/source/whatsnew/v2.0.0.rst � pandas/tests/resample/test_resample_api.py
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.
Looks fine to me
raise TypeError( | ||
f"{type(self).__name__}.sem called with " | ||
f"numeric_only={numeric_only} and dtype {self.obj.dtype}" | ||
) | ||
result = self.std(ddof=ddof, numeric_only=numeric_only_bool) | ||
result = self.std(ddof=ddof, numeric_only=numeric_only) | ||
self._maybe_warn_numeric_only_depr("sem", result, numeric_only) |
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.
is self._maybe_warn_numeric_only_depr still needed?
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.
Maybe not, but I have another branch built on this that removes it (and should be the final PR for nuisance deprecations).
small question, otherwise lgtm |
Thanks @rhshadrach |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.