-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
API: .argmax should be positional, not an alias for idxmax #16830
Comments
I am working on this at the SciPy 2017 sprints |
Added statements about correcting behavior in future commit Add reference to github ticket Fixing placement of github comment Made test code more explicit Fixing unrelated tests that are also throwing warnings Updating whatsnew to give more detail about deprecation Fixing whatsnew and breaking out tests to catch warnings Additional comments and more concise whatsnew Updating deprecate decorator to support custom message DOC: Update docstrings, depr message, and whatsnew
* Deprecating Series.argmin and Series.argmax (#16830) Added statements about correcting behavior in future commit Add reference to github ticket Fixing placement of github comment Made test code more explicit Fixing unrelated tests that are also throwing warnings Updating whatsnew to give more detail about deprecation Fixing whatsnew and breaking out tests to catch warnings Additional comments and more concise whatsnew Updating deprecate decorator to support custom message DOC: Update docstrings, depr message, and whatsnew * Added debug prints * Try splitting the filters * Reword whatsnew * Change sparse series test * Skip on py2 * Change to idxmin * Remove py2 skips * Catch more warnings * Final switch to idxmax * Consistent tests, refactor to_string * Fixed tests
…s-dev#16955) * Deprecating Series.argmin and Series.argmax (pandas-dev#16830) Added statements about correcting behavior in future commit Add reference to github ticket Fixing placement of github comment Made test code more explicit Fixing unrelated tests that are also throwing warnings Updating whatsnew to give more detail about deprecation Fixing whatsnew and breaking out tests to catch warnings Additional comments and more concise whatsnew Updating deprecate decorator to support custom message DOC: Update docstrings, depr message, and whatsnew * Added debug prints * Try splitting the filters * Reword whatsnew * Change sparse series test * Skip on py2 * Change to idxmin * Remove py2 skips * Catch more warnings * Final switch to idxmax * Consistent tests, refactor to_string * Fixed tests
…s-dev#16955) * Deprecating Series.argmin and Series.argmax (pandas-dev#16830) Added statements about correcting behavior in future commit Add reference to github ticket Fixing placement of github comment Made test code more explicit Fixing unrelated tests that are also throwing warnings Updating whatsnew to give more detail about deprecation Fixing whatsnew and breaking out tests to catch warnings Additional comments and more concise whatsnew Updating deprecate decorator to support custom message DOC: Update docstrings, depr message, and whatsnew * Added debug prints * Try splitting the filters * Reword whatsnew * Change sparse series test * Skip on py2 * Change to idxmin * Remove py2 skips * Catch more warnings * Final switch to idxmax * Consistent tests, refactor to_string * Fixed tests
The deprecation warning appears to be for
And a possible more involved change for this orpossibly for future related warnings: check whether the deprecated method is called by numpy's _wrapfunc rather than by the user directly, and avoid giving a warning if that is the case and the user code is and remains correct. |
I don't think it does? Eg
So it gives 'c', while it should give 2. But I certainly agree that it is confusing that it seems that
Is that possible? (how to do it exactly?) |
I suppose it is easy to do with inspecting the stack. Is it guaranteed to always be |
You're right. My code does:
I think this is normal though - the majority of users probably won't look at the actual value of the index.
So that's not all - there are functions like
Indeed checking that the caller is a numpy object is probably best. But having thought about it, there's probably some way to break that, e.g. by a user wrapping a call to pandas in Thanks |
That's a good point. In case you have a non-numerical index like in the small example above, the |
I just ran into this problem when working through errata for Python for Data Analysis. Can argmax/argmin return the positional values in 0.24.0? |
Generally, our rule is to keep deprecations two additional feature releases (after the first release having the warning), and only remove/change it in the release after that. For argmax/argmin, that would mean to only change it in 0.25/1.0. @wesm the reason you ask is because you actually want to get the positional value? (and don't want to resort to |
Correct, the positional value. That's what it did before the cited refactoring caused index labels to be returned |
@TomAugspurger is this closed by #30113 and #16955? |
Yes, the |
In #6214 it was reported that
argmax
changed (I think since Series didn't subclassndarray
anymore). It's sometimes useful to get the index position of the max, so it'd be nice if.argmax
did that, leavingidxmax
to always be label-based.I would expect
Out[4]
to be2
. The current workaround isnp.argmax(x)
, which is OK, but doesn't generalize to DataFrames well.We could deprecate
.argmax
in 0.21, pointing users to.idxmax
. Then later we can change.argmax
to be always be positional.Update: We've deprecated
.argmax/min
. Need to change the behavior next.The text was updated successfully, but these errors were encountered: