Alex Rivera | Logout

Get the position of the largest value in a multi-dimensional NumPy array

Asked 2010-08-27T12:46:52.633
99

How can I get get the position (indices) of the largest value in a multi-dimensional NumPy array?

Edit
Report

1 Answer

7

(edit) I was referring to an old answer which had been deleted. And the accepted answer came after mine. I agree that argmax is better than my answer.

Wouldn't it be more readable/intuitive to do like this?

numpy.nonzero(a.max() == a)
(array([1]), array([0]))

Or,

numpy.argwhere(a.max() == a)
answered 2012-02-24T12:01:45.820

Your Answer