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

DEPR: idxmin/idxmax with all-NA #54226

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Conversation

jbrockmendel
Copy link
Member

As discussed in last week's dev call.

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Jul 24, 2023
@mroeschke mroeschke added this to the 2.1 milestone Jul 24, 2023
@mroeschke mroeschke merged commit af512e6 into pandas-dev:main Jul 24, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the depr-idxmax branch July 24, 2023 20:42
jamie-harness pushed a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests
jamie-harness pushed a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests
jamie-harness pushed a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests
jamie-harness added a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests

Co-authored-by: jbrockmendel <jbrockmendel@gmail.com>
jamie-harness pushed a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests
jamie-harness added a commit to jamie-harness/pandas1 that referenced this pull request Jul 25, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests

Co-authored-by: jbrockmendel <jbrockmendel@gmail.com>
jamie-harness pushed a commit to jamie-harness/pandas1 that referenced this pull request Jul 26, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests
jamie-harness added a commit to jamie-harness/pandas1 that referenced this pull request Jul 26, 2023
* DEPR: idxmin/idxmax with all-NA

* Fix doctests

Co-authored-by: jbrockmendel <jbrockmendel@gmail.com>
@jkittner
Copy link

jkittner commented Nov 6, 2023

Am I understanding this correctly that I'm supposed to write this now each and every time I use idxmax?:

s = pd.Series([None])

if not s.isnull().all():
    m = s.idxmax()
else:
    m = np.nan

instead of just this with the originally promised behavior of "If the entire Series is NA, the result will be NA."

s = pd.Series([None])
m = s.idxmax()

this is annoyingly verbose. Or what is the correct way to approach this?

@nkonts
Copy link

nkonts commented Nov 7, 2023

this is annoyingly verbose. Or what is the correct way to approach this?

Not only is it verbose, I find it less intuitive especially considering the parameter skipna.

pd.Series([None]).idxmax(skipna=True) resulting in np.nan (and similarly for pd.DataFrame.idxmax) is (for me) the expected behavior.

nkonts added a commit to nkonts/barrier-method that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.Series idxmax raises ValueError instead of returning <NA> when all values are <NA>
4 participants