Find the row number using the first element of the row
<p>I have a <code>numpy</code> matrix where I store some kind of key in the first element of the each row (or in another way all keys are in the first column).    </p>

<pre><code>[[123,0,1,1,2],
[12,1,2,3,4],
[1,0,2,5,4],
[90,1,1,4,3]]
</code></pre>

<p>I want to get the row number searching by the key. I found that we can use <code>numpy.where</code> for this but not clear how to employ it to get the row number. I want something like</p>

<pre><code>&gt;&gt;numpy.func(myMatrix,90)
3
</code></pre>

<p>Any help would be appreciated.</p>

<p>Compare the first column with <code>90</code> within <code>np.where</code>. It will return an array of the indices of items which are equal with <code>90</code>:</p>

<pre><code>In [3]: A = np.array([[123,0,1,1,2],
[12,1,2,3,4],
[1,0,2,5,4],
[90,1,1,4,3]])


In [6]: np.where(A[:,0]==90)[0]
Out[6]: array([3])
</code></pre>

python numpy