Reputation: 529
I have an array like this :
a = np.array([[23,31,42],[16,22,56],[33,11,51]])
b = a.min()
print a
print b
So the result will be like this :
[[23 31 42]
[16 22 56]
[33 11 51]]
11
How do i get row and column of a specific value inside that array? for example :
If i want value = b where b is 11, then i'll get 2 and 1 remind that a[2][1] = 11
In my case, i need to get the row and column of the lowest value in my array.
Upvotes: 1
Views: 3508
Reputation: 58895
What you want is:
np.where(a == a.min())
if a
is an array of floats you should use instead:
np.where(np.allclose(a, a.min()))
Upvotes: 1