0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.