I want to extend following question with particular concern:
How to obtain the argmax of a[...]
in proper a
indices
>>> a = (np.random.random((10, 10))*10).astype(int)
>>> a
array([[4, 1, 7, 4, 3, 3, 8, 9, 3, 0],
[7, 7, 8, 9, 9, 6, 1, 4, 2, 0],
[6, 9, 4, 9, 2, 7, 9, 0, 8, 6],
[2, 4, 7, 8, 0, 6, 0, 7, 1, 8],
[7, 9, 7, 0, 1, 2, 3, 7, 9, 6],
[7, 1, 1, 0, 5, 1, 8, 8, 5, 5],
[5, 4, 3, 0, 0, 4, 4, 5, 5, 4],
[9, 5, 0, 5, 8, 1, 6, 4, 8, 5],
[5, 8, 0, 8, 2, 6, 4, 9, 5, 1],
[2, 5, 0, 1, 4, 0, 0, 9, 6, 4]])
>>> np.unravel_index(a.argmax(), a.shape)
(0, 7)
>>> np.unravel_index(a[a>5].argmax(), a.shape)
(0, 2)
>>> np.unravel_index(a[a>5].argmax(), a[a>5].shape)
(2,)