Selecting only columns of a numpy array where value of a specific row < x
<p>I have a numpy array similar to following structure:</p>

<pre><code>my_array = numpy.array([[1,1,1,2,2,2,3,3,3],  
                  [1,2,3,1,2,3,1,2,3],
                  [1,1,32,4,15,63,763,23,0],
                  [1,1,2,3,1,2,3,1,1],
                  [1,1,1,1,1,1,1,1,1]])
</code></pre>

<p>Now I'd like to get subset this array to get only those columns where the value in the 3rd row is &lt; 15.</p>

<p>I can get a boolean list of that as:</p>

<pre><code>list(my_array[2,:]&gt;15)
</code></pre>

<p>However I cannot use that boolean list for indexing like:</p>

<pre><code>my_array[:,list(my_array[2,:]&gt;15)]
</code></pre>

<p>Probably I have to transform that list to a list of indices and use that to subset the array, but maybe there is an in-built function or straight forward way for selecting the specific columns of the array?</p>

<p>You should not call <code>list()</code>. The input to <code>[...]</code> are supposed to be numpy arrays.</p>

<pre><code>&gt;&gt;&gt; my_array[:, my_array[2,:]&gt;15]
array([[  1,   2,   3,   3],
       [  3,   3,   1,   2],
       [ 32,  63, 763,  23],
       [  2,   2,   3,   1],
       [  1,   1,   1,   1]])
</code></pre>

python arrays numpy indexing