[Numpy-discussion] Array2 subset of array1
sebastian at sipsolutions.net
Tue Aug 5 12:33:50 EDT 2014
On Di, 2014-08-05 at 14:58 +0200, Jurgens de Bruin wrote:
> I am new to numpy so any help would be greatly appreciated.
> I have two arrays:
> array1 = np.arange(1,100+1)
> array2 = np.arange(1,50+1)
> How can I calculate/determine if array2 is a subset of array1 (falls
> within array 1)
> Something like : array2 in array1 = TRUE for the case above.
Just to be clear. You are looking for the whole of array1 (as a
block/subarray) as far as I understand. And there is no obvious numpy
way to do this. Depending on your array sizes, you could blow up the
first array from (N,) to (N-M+1,M) and then check if any row matches
completely. There may be better tricks available though, especially if
array1 is large.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion