[Numpy-discussion] (no subject)
Till Stensitzki
mail.till at gmx.de
Thu Mar 3 08:37:46 EST 2011
Alex Ter-Sarkissov <ater1980 <at> gmail.com> writes:
>
> hi, the question is probably very silly, but can't get my head around itSay
> I have an NxM numerical array. What I want is to obtain the row and
> column number of the smallest value(kinda like find command in Matlab).
> I use something like where(min(array_name)), but keep getting the error
> message. I'd be glad if any1 could have any suggestions in this
regard.cheers,Alex
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
In [24]: a=np.random.rand(3,3)
In [25]: a
Out[25]:
array([[ 0.77163699, 0.92324147, 0.20572183],
[ 0.75230562, 0.06454533, 0.23930423],
[ 0.9312196 , 0.62750468, 0.02125804]])
In [26]: np.unravel_index(a.argmin(),a.shape)
Out[26]: (2, 2)
More information about the NumPy-Discussion
mailing list