Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Now I have dataframe and list.
A B 1 a 2 b 3 c 4 d 5 e
list=[a,b,c]
I would like to drop rows by df.B refering to list.
I would like to below df
A B 4 d 5 e
How can I get this result?
You can use isin with inverted mask by ~.
isin
~
I think list is not good name in python, better is L, because list is code word and if assign variable you override it:
list
python
L
L= ['a','b','c'] print (df[~df.B.isin(L)]) A B 3 4 d 4 5 e
Add a comment
.reset_index(drop=True)
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.