[Numpy-discussion] Search array in array

Gabe Schwartz gbs25 at drexel.edu
Mon Jul 29 16:27:47 EDT 2013


Nicola Creati <ncreati <at> inogs.it> writes:

> 
> I need to search rows of A that contain elements of each row of B 
> regardless of the order of the elements in B.
> 

I don't know how fast this is, but it is fairly short:

C = (A[..., np.newaxis, np.newaxis] == B)
rows = (C.sum(axis=(1,2,3)) >= B.shape[1]).nonzero()[0]





More information about the NumPy-Discussion mailing list