我正在尝试根据以下条件筛选数据帧:
可乐=α或β
colB=伽马
我试过以下方法
filtered_df = (df[(df['colA'] == 'alpha') & (df['colB'] == 'gamma')]) | (df[(df['colA'] == 'beta') & (df['colB'] == 'gamma')])
但这不起作用,我收到以下错误消息:
TypeError: unsupported operand type(s) for |: 'str' and 'bool'
要达到预期的效果,最有希望的方法是什么?
谢谢