samol
samol

Reputation: 20610

How to slice by checkng a list of conditions in Pandas

You can slice the dataframe by a equality check

df[df['column'] == 'key']

How do I slice the dataframe via a check into a set?

df[df['column'] in set(['key', 'key2', key3'])]

Upvotes: 0

Views: 721

Answers (1)

secretive
secretive

Reputation: 2104

df[df["column"].isin(["key1", "key2", "key3"])]

This will do it.

Upvotes: 2

Related Questions