Truth Value Testing
Posted shucomputerprogram
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Truth Value Testing相关的知识,希望对你有一定的参考价值。
-
任何对象都可测试真值:
-
通过关键字‘if‘或‘while’的条件形式
-
通过Boolean 运算的操作数
-
默认下,对象都是真的,除非对象类型定义以下任一情况:
-
__bool__()方法返回False
-
当对象被调用时,__len__()方法返回zero
-
多数内置对象为Flase:
-
常数定义为None或Flase
-
数字类型为zero:0, 0.0, 0j, Decimal(0), Fraction(0, 1)
-
空的序列和集合类:‘‘, (), [], {}, set(), range(0)
-
额外说明除外,布尔值结果为0或False则为False;否则为True
以上是关于Truth Value Testing的主要内容,如果未能解决你的问题,请参考以下文章
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any()
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.
python pandas进行条件筛选时出现ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.al