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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -