Pandas argmax() deprecation message

Viewed 1448

When using argmax() it returns:

The current behaviour of Series.argmax is deprecated, use idxmax instead. The behavior of argmax will be corrected to return the positional maximum in the future. For now, use series.values.argmax or np.argmax(np.array(values)) to get the position of the maximum row. """Entry point for launching an IPython kernel.

Any ideas what this means? I have used np.argmax(np.array(values)) to get the position of the maximum row but it just returns the max value. idxmax returns another error.

1 Answers

Here is example:

import numpy as np
import pandas as pd

In[3]:
    mtx = np.random.randn(10)
    mtx

Out[3]:
    array([-1.47694909, -0.61658367, -1.2609941 ,  0.33956725,  1.69096661,
    0.10680407, -3.53473223,  0.61587513,  2.34405466, -1.49556778])

In[4]:
    ser = pd.Series(mtx)
    ser

Out[4]:
    0   -1.476949
    1   -0.616584
    2   -1.260994
    3    0.339567
    4    1.690967
    5    0.106804
    6   -3.534732
    7    0.615875
    8    2.344055
    9   -1.495568
    dtype: float64

In[5]:
    ser.idxmax()
Out[5]:
    8


In[6]:
    ser[ser.idxmax()]
Out[6]:
    2.344054659817029
Related