Skip to content

BUG: groupby.idxmin/idxmax with all NA values should raise #62026

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented Aug 2, 2025

@rhshadrach rhshadrach added Groupby API - Consistency Internal Consistency of API/Behavior Reduction Operations sum, mean, min, max, etc. labels Aug 2, 2025
@rhshadrach rhshadrach added this to the 3.0 milestone Aug 2, 2025
@rhshadrach rhshadrach requested a review from jbrockmendel August 2, 2025 18:55
index = self.obj.index
if res.size == 0:
result = res.astype(index.dtype)
elif skipna and res.lt(0).any(axis=None):
Copy link
Member

Choose a reason for hiding this comment

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

Could res.lt(0).any(axis=None) ever return a missing value that would raise if used in a bool context like this?

@@ -504,7 +504,7 @@ Renamed the following offset aliases (:issue:`57986`):

Other Removals
^^^^^^^^^^^^^^
- :class:`.DataFrameGroupBy.idxmin`, :class:`.DataFrameGroupBy.idxmax`, :class:`.SeriesGroupBy.idxmin`, and :class:`.SeriesGroupBy.idxmax` will now raise a ``ValueError`` when used with ``skipna=False`` and an NA value is encountered (:issue:`10694`)
- :class:`.DataFrameGroupBy.idxmin`, :class:`.DataFrameGroupBy.idxmax`, :class:`.SeriesGroupBy.idxmin`, and :class:`.SeriesGroupBy.idxmax` will now raise a ``ValueError`` when a group has all NA values, or when used with ``skipna=False`` and any NA value is encountered (:issue:`10694`)
Copy link
Member

Choose a reason for hiding this comment

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

does 10694 cover both of these cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Groupby Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: groupby.idxmin/idxmax will all NA values
3 participants