python-获取满足条件的索引值np.where
想要获取满足条件的索引值,需要用到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,
·
想要获取满足条件的索引值,需要用到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.
返回结果不是元组,直接返回坐标索引。
更多推荐
所有评论(0)