Find all occurences of a specified match of two numbers in numpy array
<p>what i need to achieve is to get array of all indexes, where in my data array filled with zeros and ones is step from zero to one. I need very quick solution, because i have to work with milions of arrays of hundrets milions length. It will be running in computing centre. For instance..</p>

<pre><code>data_array = np.array([1,1,0,1,1,1,0,0,0,1,1,1,0,1,1,0])
result = [3,9,13]
</code></pre>

<p>Here's the procedure:</p>

<ol>
<li>Compute the diff of the array</li>
<li>Find the index where the diff == 1</li>
<li>Add 1 to the results (b/c <code>len(diff) = len(orig) - 1</code>)</li>
</ol>

<p>So try this:</p>

<pre><code>index = numpy.nonzero((data_array[1:] - data_array[:-1]) == 1)[0] + 1
index
# [3, 9, 13]
</code></pre>

python arrays performance numpy