[Numpy-discussion] Array search considering order
andrei at ruivo.org
Fri Dec 20 06:41:04 EST 2013
On Fri, Dec 20, 2013 at 11:19:49AM +0000, Oscar Benjamin wrote:
> Date: Fri, 20 Dec 2013 11:19:49 +0000
> From: Oscar Benjamin <oscar.j.benjamin at gmail.com>
> To: Discussion of Numerical Python <numpy-discussion at scipy.org>
> Subject: Re: [Numpy-discussion] Array search considering order
> On 19 December 2013 16:49, Andrei Rozanski <andrei at ruivo.org> wrote:
> > Sorry if I was not clear enough.
> > The SO question is alike what I want. However, in my problem, Im not sure if there will be only one occurence.
> > What I do expect is:
> > Given one array (big one), to retrieve indexes for "query array" occurences.
> > Something like that:
> > array1(big one) - 1,2,3,4,5,6,7,1,2,3,4,5,7,8,9,1,2,3,4,5,6,7,8
> > array2(query) - 1,2,3
> > array3(another query) - 8,7,6
> > result (array1 versus array2) - 0,7,15 (position for match)
> > result (array1 versus array3) - no matches
> If you look more closely at the SO question you'll see that it does
> answer your problem. The top-rated answer shows how to get an boolean
> array indicating where the matches are. In your case that would be
> [True, False, False, False, False, False, False, True, False, False,
> False, False, False, False, False, True, False, False, False, False,
> Now just use the numpy.where function to get the indices of the True
> value from this array.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
Thank you for the help.
Indeed. My lack of knowledge on numpy functions didnt aloud my to get that.
That works for me.
More information about the NumPy-Discussion