number = [[1,2],[3,2]]
num = np.array(number)
np.argwhere(num=2)
np.argwhere(num==2)
array([[0, 1],
[1, 1]], dtype=int64)
注意:只能是维度相同的时候,才能用该方法。
om ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with diffe
rent lengths or shapes) is deprecated. If you meant to do this, you must specify ‘dtype=object’ when creating the ndarray
np.argwhere(num==2)
array([], shape=(0, 1), dtype=int64)np.argwhere(num==3)
array([], shape=(0, 1), dtype=int64)