
On 19 December 2013 16:49, Andrei Rozanski andrei@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, False]
Now just use the numpy.where function to get the indices of the True value from this array.
Oscar