[Numpy-discussion] Lookup array

Bob Dowling rjd4+numpy at cam.ac.uk
Mon Oct 10 05:03:48 EDT 2011


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?)

-- 
Bob Dowling



More information about the NumPy-Discussion mailing list