0

I am having this DataFrame.

A     b        c            d           e           f            g
1   2022    0.875000    1.406061    0.813333    1.500000    0.771429
2   2023    0.859060    1.090688    0.880546    1.114286    0.902778
3   2061    0.806452    0.951600    0.776398    0.946970    0.757576
4   2062    0.923077    1.056189    0.930970    1.042930    0.940000
5   2067    0.000000    0.000000    1.000000    0.000000    0.000000
6   2085    0.835821    1.110215    0.862903    0.872054    0.894737
7   2092    0.000000    0.000000    1.000000    0.000000    0.000000
8   2129    0.764706    1.094737    0.793103    1.126667    0.833333

list =['2062','2129']

I want to drop all the rows, where value in the list is equal to the column b.

What is the most efficient way to achieve this?

Abhik Sarkar
  • 901
  • 3
  • 12
  • 32

1 Answers1

2
new_df=df[~df['b'].isin(mylist)]
Pyd
  • 6,017
  • 18
  • 52
  • 109