Skip to content

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
Abhay-2004:GH-53098-numeric-only-validation
Open

DEPR: Deprecate passing non-bool value for numeric_only in reductions (GH#53098)#64917
Abhay-2004 wants to merge 3 commits intopandas-dev:mainfrom
Abhay-2004:GH-53098-numeric-only-validation

Conversation

@Abhay-2004
Copy link
Copy Markdown

@Abhay-2004 Abhay-2004 commented Mar 30, 2026

Summary

  • Passing a non-bool, non-None value for numeric_only in reduction methods
    (sum, mean, min, max, prod, median, sem, var, std, skew,
    kurt) currently silently coerces the value. This PR deprecates that behavior
    by emitting a Pandas4Warning — the value is still coerced for now, but will
    raise in a future version.

  • The deprecation logic is added to the existing validate_bool_kwarg utility
    via a new deprecated=True parameter, keeping the change centralised and
    reusable.

  • The three internal dispatch methods in NDFrame (_stat_function,
    _stat_function_ddof, _min_count_stat_function) now call
    validate_bool_kwarg(numeric_only, "numeric_only", none_allowed=False, deprecated=True)

  • closes ERR: numeric_only in 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.rst file 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.

@Abhay-2004 Abhay-2004 changed the title BUG: Raise ValueError when numeric_only is not bool or None (GH#53098) DEPR: Deprecate passing non-bool value for numeric_only in reductions (GH#53098) Mar 30, 2026
@Abhay-2004 Abhay-2004 force-pushed the GH-53098-numeric-only-validation branch from c1baa34 to 99ae0ac Compare March 30, 2026 04:49
@Abhay-2004 Abhay-2004 force-pushed the GH-53098-numeric-only-validation branch from 99ae0ac to 6b33fe2 Compare March 30, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR: numeric_only in reduction operations should disallow passing non-bools

1 participant