Python/NumPy first occurrence of subarray

The following code should work:

[x for x in xrange(len(a)) if a[x:x+len(b)] == b]

Returns the index at which the pattern starts.

Leave a Comment