
import Numeric, sys a = Numeric.array([1,2,1,2,4,3,1,2,3,2,3,2]) b = Numeric.array([4,3,5,2,4,5,3,6,3,2,5,6]) c = Numeric.arange(len(b)) print c[Numeric.argmin(Numeric.where(a==1, b, sys.maxint))] -----Original Message----- From: numpy-discussion-admin@lists.sourceforge.net [mailto:numpy-discussion-admin@lists.sourceforge.net] On Behalf Of Michaell Taylor Sent: Monday, January 28, 2002 12:59 PM To: numpy-discussion@lists.sourceforge.net Subject: [Numpy-discussion] conditional array indexing Very new user to Numpy, so excuse the question. It relates to a fundamental issue which I have having trouble getting a grip on. Specifically, say I have the following: a = ([1,2,1,2,4,3,1,2,3,2,3,2]) b = ([4,3,5,2,4,5,3,6,3,2,5,6]) c = random variable of length=len(b) I would like to get the value of C associated with the lowest value of b within groupings of a. That is, there are three incidents of "1" in the a array. The lowest value of b associated with the value 1 in the a index is "3". This occurs in index value 6 on the a and b arrays. Now, I would like to then know the value of c[6]. Obviously the real problem is far more complex with len(a)==5000. Any ideas? Thanks in advance. Michaell _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion