[Numpy-discussion] Lookup array

Andrey N. Sobolev inconnu at list.ru
Mon Oct 10 05:17:41 EDT 2011


В Mon, 10 Oct 2011 10:03:48 +0100
Bob Dowling <rjd4+numpy at cam.ac.uk> пишет:

> 
> On 10/10/11 09:53, Andrey N. Sobolev wrote:
> 
> > I have 2 arrays - A with the dimensions of 1000x4 and B with the
> > dimensions of 5000x4. B doesn't (hopefully) contain any rows that
> > are not in A. I need to create a lookup array C, the i-th value of
> > which will be the index of B[i] in A. In the (very rare) case when
> > B[i] is not in A C[i] should be equal to -1.
> 
> May we assume that there are no repeats in A?  (i.e. no cases where
> two different indices are both valid?)
> 

Yes, rows in A are unique and sorted.
One more typo found - instead of np.which in the previous e-mail it has
to be np.where, I don't know what I thought about :)

Thanks in advance!
Andrey




More information about the NumPy-Discussion mailing list