Reputation: 39
Easy question here: I am creating a new data frame based on a report of contracts where I only want 2 statuses. I have the first one, but am having trouble adding the second condition.
df2 = df[(df['[PCW] Contract Status'] == "Draft")]
The other status is "Draft Amendment". So I basically want it to read like
df2 = df[(df['[PCW] Contract Status'] == "Draft", "Draft Amendment")]
Upvotes: 0
Views: 100
Reputation: 1215
You can use isin()
.
df2 = df[df['[PCW] Contract Status'].isin(["Draft", "Draft Amendment"])]
Or else you can create the list of required variables earlier and then add the name of the list in isin()
.
Upvotes: 2