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>According to the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html#numpy.where" rel="nofollow">online doc</a>, <code>numpy.where</code> if you give it only a boolean array will return lists of coordinates (one list per dimension) for the elements that are <code>True</code>.
So we can get the information you want by grabbing the first column of your array , comparing it with the element you want to find and calling np.where on that boolean array. All that would look like that:</p>

<pre><code>row,column=np.where(myMatrix[;,0]==90) 
#Note that column will just be 0 here
</code></pre>

python numpy