-
-
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
BUG: pandas 0.13 Series argmax/argmin returns index label instead of location (changed from 0.12) #6214
Comments
these are equivalent are aliases to idxmin/idxmax you could get the index position by doing s.index.get_loc(s.idxmax()) for example or prior to 0.13 iIIRC argmin/ max were just pass thrus to numpy |
Ok, the new behavior is more intuitive. It's probably good to mentioned the change in 0.13 release note. |
Just a quick note on the suggestions above:
will not work to get the index position, however
or
does. |
Hmm. Looking back over this, I don't think it was a good idea to change this from the old behavior -- argmax is useful independently of idxmax. Probably too late to change back now, though. |
I agree. It seems superfluous to have them perform the same function when having argmax do something different would have been useful, as you point out. |
In addition to the above no.argmax() Snnth note You could load data file (mixed string and numerical) i.e., csv file using pandas The above error message can be addressed by either uploading data using loadtxt('filename1.csv') in which the filename1.csv does not contain strings or even common delimiters. On the other hands, df.idxmax would work on pandas loaded data that has strings and numerical. But it does not give you the index. |
------------------------ pandas 0.12 --------
In [14]: pd.version
Out[14]: '0.12.0'
In [15]: a=pd.Series(range(3), index=('2','3','4'))
In [16]: a.argmax()
Out[16]: 2
In [17]: a.idxmax()
Out[17]: '4'
------------------------ pandas 0.13 --------
In [2]: pd.version
Out[2]: '0.13.0'
In [3]: a=pd.Series(range(3), index=('2','3','4'))
In [4]: a.argmax()
Out[4]: '4'
In [5]: a.idxmax()
Out[5]: '4'
The text was updated successfully, but these errors were encountered: