python pandas loc - filter for list of values -
this question has answer here:
this should incredibly easy, can't work.
i want filter dataset on 2 values.
#this works, when filter 1 value df.loc[df['channel'] == 'sale'] #if have filter, 2 separate columns, can df.loc[(df['channel'] == 'sale')&(df['type]=='a')] #but if want filter 1 column more 1 value? df.loc[df['channel'] == ('sale','fullprice')]
would have or statement? can in sql using in?
there exists df.isin(values)
method tests whether each element in dataframe contained in values. so, @maxu wrote in comment, can use
df.loc[df['channel'].isin(['sale','fullprice'])]
to filter 1 column multiple values.
wiki
Comments
Post a Comment