numpy.argwhere(Y==0)
- 返回 Array Y中所有值为0的值的索引
- - argwhere: arg(argument的缩写),where(表示索引在哪里)。
X,Y=sklearn.datasets.make_moons(10,noise=0.2)
print(Y)
print("==================")
print(np.argwhere(Y==0))
[1 0 0 1 0 0 1 0 1 1]
==================
[[1]
[2]
[4]
[5]
[7]]
>>> x = np.arange(6).reshape(2,3)
>>> x
array([[0, 1, 2],
[3, 4, 5]])
>>> np.argwhere(x>1)
array([[0, 2],
[1, 0],
[1, 1],
[1, 2]])