1
我怎样才能实现对过滤NOT条件大熊猫不能与过滤条件
grouped = store_ids_with_visits.groupby(level=[0, 1, 2])
grouped.filter(lambda x: (len(x) == 1 and x['template_fk'] == exterior_template))
我想不是的条件回答所有条目
我试图做:
grouped.filter(lambda x: ~(len(x) == 1 and x['template_fk'] == exterior_template))
但出现以下错误:
filter function returned a int, but expected a scalar bool
试着用'not'替换'〜'(按位NOT运算符) - 例如'not(len(x)...' – jedwards
@jedwards用这个我得到'一个系列的真值不明确' –
在你的数组中使用'any'或'all'内建函数 –