Drop the smallest value from pandas Series

Viewed 704

I have a pandas.Series:

Name: vector, dtype: float64
1     74.67
2     87.78
3     97.00

I want to drop the smallest value from Series. I managed to do:

vector = vector[vector != vector.min()]

But what if my Series has got somewhat identical the smallest values like this:

Name: vector, dtype: float64
1     74.67
2     87.78
3     74.67

I would like to drop only one values and leave another one and get Series:

Name: vector, dtype: float64
2     87.78
3     74.67

How can I implement that?

3 Answers

You can use idxmin() to get index of the first smallest value and drop:

s.drop(s.idxmin())

Get index of first minimal value by Series.idxmin and then drop by Series.drop:

vector = vector.drop(vector.idxmin())
print (vector)
2    87.78
3    97.00
Name: vector, dtype: float64

You can do

s=s.sort_values(ascending=False).iloc[1:]
Related