這應該是非常容易,但我不能讓它工作。python pandas loc - 過濾器的值列表
我想過濾我的數據集的兩個值。
#this works, when I filter for one value
df.loc[df['channel'] == 'sale']
#if I have to filter, two separate columns, I can do this
df.loc[(df['channel'] == 'sale')&(df['type]=='A')]
#but what if I want to filter one column by more than one value?
df.loc[df['channel'] == ('sale','fullprice')]
這是否必須是OR語句?我可以在SQL中使用類似的東西嗎?
'df.loc [df ['channel']。isin(['sale','fullprice'])]' – MaxU
非常感謝! – jeangelj