can argmax be used to return row and column indices?

Hello list, I am trying to find the indices of the maximum value in a 2D array. argmax works fine, but returns the index in the flattened array. That is often not very convenient. Is there a function that returns the index of the row and column? Or can the index of the flattened array easily be converted to the row can column indices (I know, I can write a function for that, but I figure numpy already has one). Thanks, Mark

Hi Mark, You're looking for "np.unravel_index" function. Cheers, Gregorio 2013/9/13 Mark Bakker <markbak@gmail.com>:
Hello list,
I am trying to find the indices of the maximum value in a 2D array. argmax works fine, but returns the index in the flattened array. That is often not very convenient. Is there a function that returns the index of the row and column? Or can the index of the flattened array easily be converted to the row can column indices (I know, I can write a function for that, but I figure numpy already has one).
Thanks,
Mark
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (2)
-
Gregorio Bastardo
-
Mark Bakker