title: Extracting specific columns in numpy array by condition
body: <p>I have a homework assignment to extract a 2-dimensional numpy array out of another 2-dimensional np array by choosing specific columns by condition (not by range).</p>
  
  <p>So I have an array <code>A</code> with shape <code>(3, 50000)</code>. I am trying to get a new array with shape <code>(3, x)</code> for some <code>x &lt; 50000 with the original columns of</code>A<code>that satisfy the third cell in the column is</code>-0.4 &lt; z &lt; 0.1`.</p>
  
  <p>For example if:</p>
  
  <pre><code>A = [[1,2,3],[2,0.5,0],[9,-2,-0.2],[0,0,0.5]]
  </code></pre>
  
  <p>I wish to have back:</p>
  
  <pre><code>B = [[2,0.5,0],[9,-2,-0.2]
  </code></pre>
  
  <p>I have tried to make a bool 1 rank array that holds true on the columns I want, and to some how combine between the two. The problem it's output is 1 rank array which is not what I am looking for. And I got some ValueErrors..</p>
  
  <pre><code>bool_idx = (-0.4 &lt; x_y_z[2] &lt; 0.1)
  </code></pre>
  
  <p>This code made some troubles: </p>
  
  <pre><code>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  </code></pre>
  
  <p>I can do it with some loops but NumPy got so many beautiful function I am sure I am missing something here..</p>