ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any()

在使用pandas判断数据时出现错误提示:pandas

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().it

我的理解:这是由于,你将一个值与多个值或一个列表中的值相比较、匹配,致使的问题class

看提示,咱们能够知道,在比较前,咱们能够使用它推荐的某个方法:方法

a.empty    if(a.empty):print("!!")    判断a是否为空数据

a.item()     没有用过,应该a.item(i)  表示第i个节点di

a.any()       if(a.any() in [1,2,3,4]):print("!!")    判断 a中的任意一个值是否在[1,2,3,4]中co

a.all()         if(a.all() in [1,2,3,4]):print("!!")    判断 a中的全部值是否在[1,2,3,4]中错误

错误提示的意思应该就是 所选的真值不明确 也就是你给的值和做比较的值两个不是一个类型的

相关文章
相关标签/搜索