如何在筛选上实现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
IIUC,您可以使用^{} 检查bool条件,并仅获取分组数据帧的
NOT(~)
值:相关问题 更多 >
编程相关推荐