2.3.4 比较函数

函数功能说明示例代码示例输出
np.greater(a, b)元素级比较 a > bnp.greater([3, 1], [2, 2])[True, False]
np.less(a, b)元素级比较 a < bnp.less([3, 1], [2, 2])[False, True]
np.equal(a, b)元素级比较 a == bnp.equal([1, 2], [1, 3])[True, False]
np.logical_and(a, b)逻辑与(逐元素)np.logical_and([True, False], [True, True])[True, False]
np.logical_or(a, b)逻辑或(逐元素)np.logical_or([True, False], [False, False])[True, False]
np.logical_not(a)逻辑非(逐元素)np.logical_not([True, False])[False, True]
np.any(a)检查数组中是否 至少有一个元素 为 Truenp.any([0, 1, 0])True
np.all(a)检查数组中是否 所有元素 为 Truenp.all([1, 2, 0])False
np.where(condition, x, y)根据条件选择元素np.where([True, False, True], 1, 0)[1, 0, 1]

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发
头像-大赛人网
欢迎您留下宝贵的见解!
提交
头像-大赛人网

昵称

取消
昵称

    请登录后查看评论内容