Here's how to do it in numpy. Please see numpy.argmax , which returns the maximum value indices along the axis. Note that these indexes are based on 0, so you might want to add / subtract 1 on it to make it 1 based on like in matlab.
Taking the same example @Stewie Griffin :-)
In [3]: a = np.array([[16,2,3,13], [5,11,10,8], [9,7,6,12], [4,14,15,1]]) In [4]: N = 2
Here the axis is 0 because you want the maximum indices in each column. Change it to 1 if you want maximum indices in each raw. Also numpy.argmin if you want min.
Based on your explanation, you want the nth largest indices in each column, which is very easy with numpy.argsort .
In [11]: A = np.argsort(a, axis=0)
mg007 source share