| 函数 | 功能说明 | 示例代码 | 示例输出 |
| np.greater(a, b) | 元素级比较 a > b | np.greater([3, 1], [2, 2]) | [True, False] |
| np.less(a, b) | 元素级比较 a < b | np.less([3, 1], [2, 2]) | [False, True] |
| np.equal(a, b) | 元素级比较 a == b | np.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) | 检查数组中是否 至少有一个元素 为 True | np.any([0, 1, 0]) | True |
| np.all(a) | 检查数组中是否 所有元素 为 True | np.all([1, 2, 0]) | False |
| np.where(condition, x, y) | 根据条件选择元素 | np.where([True, False, True], 1, 0) | [1, 0, 1] |
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END











请登录后查看评论内容