返回整行,其中包含numpython中的最大值

返回整行,其中包含numpython中的最大值,numpy,Numpy,我还想打印行[0,6]。对于axis,它还返回来自其他行的所有值。argmax不返回行索引。一种方法是使用np.where返回索引where true: val = np.array([[1, 3], [2, 5], [0, 6], [1, 2] ]) print(np.max(val)) 6 输出: r,_ = np.where(val == np.max(val)) val[r] array([[0, 6]])

我还想打印行[0,6]。对于axis,它还返回来自其他行的所有值。argmax不返回行索引。

一种方法是使用np.where返回索引where true:

val = np.array([[1, 3], [2, 5], [0, 6], [1, 2] ])
print(np.max(val))
6
输出:

r,_ = np.where(val == np.max(val))
val[r]
array([[0, 6]])