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.

1

1 Answer 1

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()))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.