1

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.

Faizalprbw
  • 529
  • 1
  • 6
  • 17
  • possible duplicate of [Is there a Numpy function to return the first index of something in an array?](http://stackoverflow.com/questions/432112/is-there-a-numpy-function-to-return-the-first-index-of-something-in-an-array) – innoSPG Jul 30 '15 at 23:12

1 Answers1

1

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()))
Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234