returning index of minimum in a list of lists

Bas wegwerp at gmail.com
Wed Jun 21 18:02:58 EDT 2006


JJLaRocque at gmail.com wrote:
> Thanks so much for your help.  I was wondering if there was anything
> even simpler, but this will be great.

>>> from numpy import *
>>> a=array([[3,3,3,3], [3,3,3,1], [3,3,3,3]])
>>> where(a==a.min())
(array([1]), array([3]))

Probably overkill for your simple problem, but this is a nice
alternative if you do a lot of matrix work.

Bas




More information about the Python-list mailing list