How to find index of minimum element in pandas

Viewed 36

I have the following series:

0     0.0149
1    0.00088
2    0.00322
3    0.00357
4     0.0101

Of type and shape: dtype: object <class 'pandas.core.series.Series'> (5,)

I am trying to return the index of the minimum element +1, in this case 2

I have tried the following methods idxmin() and argmin() but keep getting

TypeError: reduction operation 'argmin' not allowed for this dtype

1 Answers

Convert values of Series to numeric before using Series.idxmin:

out = s.astype(float).idxmin() + 1
Related