Skip to content

Conversation

@divya1974
Copy link
Contributor

@divya1974 divya1974 commented Oct 8, 2025

Ran tests:
Groupby tests: 29766 passed, 440 skipped, 45 xfailed, 39 xpassed, 1 warning.
Window tests (with Numba disabled to avoid an env crash): 9869 passed, 28 skipped, 91 xfailed.
Frame reductions tests: 2338 passed, 2 xfailed.
No real test failures (only xfails/skips) after applying the deprecation behavior.

Changes
Implemented the deprecation approach for numeric_only=None during the 2.x cycle:

  • Added deprecate_numeric_only_none helper in _validators.py
  • Wired the helper + validate_bool_kwarg(..., none_allowed=True) into:
    frame.py : (DataFrame._reduce)
    series.py : (Series._reduce)
    groupby.py :(GroupBy._cython_agg_general)
    rolling.py : (Rolling._validate_numeric_only)
  • Updated tests in [test_reductions.py] to assert the deprecation warning using tm.assert_produces_warning
  • Added a whatsnew note in v2.1.0.rst documenting the deprecation.

…ne during 2.x)\n\nAdds a centralized helper that emits a PandasFutureWarning for numeric_only=None to support a warn-first migration (GH#53098).
…recate_numeric_only_none and validate_bool_kwarg at central reduction entry points (DataFrame._reduce, Series._reduce, GroupBy._cython_agg_general, Rolling._validate_numeric_only). Emit PandasFutureWarning for numeric_only=None (GH#53098).
…numeric_only=None using tm.assert_produces_warning
@divya1974 divya1974 requested a review from rhshadrach as a code owner October 8, 2025 23:54
@divya1974
Copy link
Contributor Author

I see some tests failing, which I couldn't catch locally. Any suggestion on what I am missing will be helpful.

@Alvaro-Kothe
Copy link
Member

Some of them can be fixed if you merge from main.

# validate numeric_only is strictly a bool (disallow None, ints, etc.)
# Deprecate passing None to numeric_only: warn now, error in a future
# release. See GH#53098.
from pandas.util._validators import deprecate_numeric_only_none
Copy link
Member

Choose a reason for hiding this comment

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

do this import at the top of the file

# Note: we never get here with how="ohlc" for DataFrameGroupBy;
# that goes through SeriesGroupBy

# validate numeric_only is strictly a bool (disallow None, ints, etc.)
Copy link
Member

Choose a reason for hiding this comment

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

this comment can go in the implementation of deprecate_numeric_only_none, is not needed at every place where it is called

# New behavior: numeric_only=None is deprecated; emit a warning but
# continue to accept it during the deprecation period.
if numeric_only is None:
from pandas import errors
Copy link
Member

Choose a reason for hiding this comment

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

top of the file, should probably be Pandas4Warning?

return value


# deprecate_numeric_only_none defined later in file
Copy link
Member

Choose a reason for hiding this comment

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

not needed

"""
import warnings

from pandas import errors
Copy link
Member

Choose a reason for hiding this comment

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

top of the file

f'Passing None for "{arg_name}" is deprecated and will raise a '
"ValueError in a future version; please pass True or False."
)
warnings.warn(msg, errors.PandasFutureWarning, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

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

use stacklevel=find_stack_level()

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

3 participants