Getting TypeError: reduction operation ‘argmax’ not allowed for this dtype when trying to use idxmax()

The type of the cell values are, by default, non-numeric. argmin(), idxmin(), argmax() and other similar functions need the dtypes to be numeric.

The easiest solution is to use pd.to_numeric() in order to convert your series (or columns) to numeric types. An example with a data frame df with a column 'a' would be:

df['a'] = pd.to_numeric(df['a'])

A more complete answer on type casting on pandas can be found here.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)