2

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?

Yaroslav Hladkyi
  • 305
  • 2
  • 13

3 Answers3

4

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

s.drop(s.idxmin())
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
1

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
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
1

You can do

s=s.sort_values(ascending=False).iloc[1:]
BENY
  • 317,841
  • 20
  • 164
  • 234