Skip to content
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

CLN: Enforce deprecation of argmin/max and idxmin/max with NA values #57971

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented Mar 23, 2024

  • closes #xxxx (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.

Ref: #33941, #51276

This is complicated by #57745 - we still need a proper deprecation for groupby's idxmin/idxmax. For DataFrame with EAs and axis=1, we use groupby's implementation. So I'm leaving that deprecation in place for now, and we can enforce it after groupby's is deprecated and ready to be enforced.

@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Clean Reduction Operations sum, mean, min, max, etc. labels Mar 23, 2024
@mroeschke mroeschke added this to the 3.0 milestone Mar 25, 2024
@mroeschke mroeschke merged commit 63cad6b into pandas-dev:main Mar 25, 2024
46 checks passed
@mroeschke
Copy link
Member

Thanks @rhshadrach

raise ValueError("Encountered all NA values")
elif not skipna and isna(delegate).any():
raise ValueError("Encountered an NA value with skipna=False")

Copy link
Member

Choose a reason for hiding this comment

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

huh IIRC the idea with the deprecation was that eventually we'd be able to make this method just return self.array.argmax(skipna=skipna)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks - makes sense. Right now the various arrays raise NotImplementedError. I think changing this to a ValueError will make this doable. Will followup.

One other mistake I've realized here (thanks to #58013) - I thought it would be more helpful to raise "all NA values" even when skipna=False if all values are NA, but that requires doing an extra O(n) check. I plan to change the message to "Encountered an NA value with skipna=False" even when all values are NA for perf.

Copy link
Member

Choose a reason for hiding this comment

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

i might be confusing this with argsort; there is a TODO(3.0) comment in Series.argsort about using self.array.argsort directly

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…andas-dev#57971)

* CLN: Enforce deprecation of argmin/max and idxmin/max with NA values

* Docstrings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants