np.searchSorted over 2D array

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Dec 10 14:55:31 EST 2015


On 10 Dec 2015 14:46, "Heli" <hemla21 at gmail.com> wrote:
>
> Thanks Peter,
>
> I will try to explain what I really need.
>
> I have a 3D numpy array of 100*100*100 (1M elements). Then I have another
numpy array of for example 10*2*10 (200 elements). I want to know if in the
bigger dataset of 100*100*100, there is anywhere, where the second numpy
array of 200 elements with shape 10*2*10 appears. If it does, then I want
the indices of the bigger dataset where this happens.
>

So you want to find N in M. First find all occurrences of N[0][0][0] in
M[:90][:98][:90]. Then for each of those extract the same size subview from
M and check if (Ms == N).all().

--
Oscar



More information about the Python-list mailing list