我有一个numpy一维数组,其中包含Trueor的布尔值False。我想检查是否所有的元素都返回False一个,无论数组中的所有元素是 False 还是 TrueTrue/Falsenumpy
x = np.array([False, False, False]) # this should return True, since all values are False
y = np.array([True, True, True]) # this should return False, since all values are True
z = np.array([True, False, True]) # this should return False, since not all values are False
Run Code Online (Sandbox Code Playgroud)
我调查过np.all(),但这并不能解决我的问题。
谢谢!
比较每个项目False,然后减少使用np.all
np.all(x == False)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15369 次 |
| 最近记录: |