Maxim Dunavicher
Maxim Dunavicher

Reputation: 635

Data frames pandas python

I have a data frame that looks like this:

id  age sallary
1    16   500
2    21   1000
3    25   3000
4    30   6000
5    40   25000

and a list of ids that I would like to ignore [1,3,5]

how can I get a data frame that will contain all the remaining rows: 2,4.

Big thanks for every one.

Upvotes: 0

Views: 39

Answers (1)

EdChum
EdChum

Reputation: 394459

Call isin and negate the result using ~:

In [42]:

ignore_ids=[1,3,5]
df[~df.id.isin(ignore_ids)]
Out[42]:
   id  age  sallary
1   2   21     1000
3   4   30     6000

Upvotes: 1

Related Questions