这应该是非常容易,但我不能让它工作。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