pandas removes rows conditionally on 2 variable values

时间:2019-04-16 22:27:19

标签: pandas dataframe

I have a gender column and I only want to drop the ones that are not "MALE" or "FEMALE". How can I use a conditional with 2 variables.

I tried :

train2=train[train.gender = ("FEMALE" | "MALE")]

gives me the error :

SyntaxError: invalid syntax

I could maybe only do one conditional , save it in 2 variables, and then stitch them together again somehow, but that seems very inefficient.

0 个答案:

没有答案