DEPR: Deprecate passing non-bool value for numeric_only in reductions (GH#53098)#64917
Open
Abhay-2004 wants to merge 3 commits intopandas-dev:mainfrom
Open
DEPR: Deprecate passing non-bool value for numeric_only in reductions (GH#53098)#64917Abhay-2004 wants to merge 3 commits intopandas-dev:mainfrom
Abhay-2004 wants to merge 3 commits intopandas-dev:mainfrom
Conversation
c1baa34 to
99ae0ac
Compare
99ae0ac to
6b33fe2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Passing a non-bool, non-
Nonevalue fornumeric_onlyin reduction methods(
sum,mean,min,max,prod,median,sem,var,std,skew,kurt) currently silently coerces the value. This PR deprecates that behaviorby emitting a
Pandas4Warning— the value is still coerced for now, but willraise in a future version.
The deprecation logic is added to the existing
validate_bool_kwargutilityvia a new
deprecated=Trueparameter, keeping the change centralised andreusable.
The three internal dispatch methods in
NDFrame(_stat_function,_stat_function_ddof,_min_count_stat_function) now callvalidate_bool_kwarg(numeric_only, "numeric_only", none_allowed=False, deprecated=True)closes ERR:
numeric_onlyin reduction operations should disallow passing non-bools #53098 (Replace xxxx with the GitHub issue number)Tests added and passed if fixing a bug or adding a new feature
All code checks passed.
Added type annotations to new arguments/methods/functions.
Added an entry in the latest
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.I have reviewed and followed all the contribution guidelines
If I used AI to develop this pull request, I prompted it to follow
AGENTS.md.