pandas 熊猫没有过滤条件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38681802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 01:42:36 来源:igfitidea点击:
pandas not condition with filtering
提问by Night Walker
How I can implement not condition on the filtering
我如何在过滤中实现非条件
grouped = store_ids_with_visits.groupby(level=[0, 1, 2])
grouped.filter(lambda x: (len(x) == 1 and x['template_fk'] == exterior_template))
I want to get all entries that not answering on the condition
我想获得所有不满足条件的条目
I tried doing:
我试着做:
grouped.filter(lambda x: ~(len(x) == 1 and x['template_fk'] == exterior_template))
But got following error:
但得到以下错误:
filter function returned a int, but expected a scalar bool