You can use Numpy's argmax() / argmin() functions that return the indexes of the first occurrences of the maximum/minimum values along the specified axis.
Here is an example:
>>> import numpy as np>>> aa=np.matrix([[3,1,4,6],[12,45,6,9],[89,0,5,19]])>>> aa.argmin(axis=0)matrix([[0, 2, 0, 0]])>>> aa.argmin(axis=1)matrix([[1], [2], [1]])>>> aa.argmax(axis=0)matrix([[2, 1, 1, 2]])>>> aa.argmax(axis=1)matrix([[3], [1], [0]])