想要获取满足条件的索引值,需要用到np.where

1.np.where(condition, x, y)
x:满足条件时函数的输出
y:不满足条件时的输出

2.np.where(condition)
没有x和y参数,则以元组形式输出满足条件的列表索引。

3.np.argwhere(condition)
Find the indices of array elements that are non-zero, grouped by element.
返回结果不是元组,直接返回坐标索引。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐