Skip to content

Improve error message in Series.any and Series.all, when bool_only is passed and not level #38810

Closed
@moink

Description

@moink

When working on xref #30999 I came across TestSeriesReductions.test_all_any_params in pandas/tests/reductions/test_reductions.py

It showed that calling the following code:

s = Series([False, False, True, True, False, True], index=[0, 0, 1, 1, 2, 2])
s.any(bool_only=True)

would raise a NotImplementedError with the error message "Series.any does not implement numeric_only", and equivalent for calling s.all the same way. This error message is confusing because the user didn't pass numeric_only, they passed bool_only.

So the messages need to change to "Series.any does not implement bool_only" and "Series.all does not implement bool_only".

what actually needs to happen is we pass bool_only thru, but this increases the scope of this PR greatly.
-- @jreback #38720

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions