[Numpy-discussion] Get the index of a comparison of two lists
Andreas.FRENK at 3ds.com
Fri Feb 11 09:01:08 EST 2011
I need to create a construct that returns the index of entries of the first list, if values in the first and second list are equal.
valA = [1,2,3,4,20,21,22,23,24]
valB = [1,2,3,4, 5,21,22,23]
The correct solution is: [0,1,2,3,5,6,7]
A potential loop can be:
for j,a in enumerate(valA):
if a in valB:
Please note, valA can have entries like [1,10000000,1000000001,.....], i.e. it can be very sparse.
I also thought about using bincount, but due to the sparse nature the return values from bincount would allocate too much memory.
Any idea how to do it fast using numpy?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion