minimum() function is used to find the element-wise minimum of array elements. It compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned.
min to return the minimum value, or equivalently for an array arrname use arrname. min() . As you mentioned, numpy. argmin returns the index of the minimum value (of course, you can then use this index to return the minimum value by indexing your array with it).
Use unravel_index
:
numpy.unravel_index(A.argmin(), A.shape)
[Corrected typo]
Another simple solution is
ri, ci = A.argmin()//A.shape[1], A.argmin()%A.shape[1]
As numpy.argmin returns the index reading in row-major order
Yes, you are right, it was a typo, which worked for square matrix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With