title: How to filter a numpy array using another array's values?
body: <p>I have two NumPy arrays, e.g.:</p>
  
  <pre><code>a = [1,2,3,4,5]
  </code></pre>
  
  <p>and a filter array, e.g.:</p>
  
  <pre><code>f = [False, True, False, False, True]
  
  len(a) == len(f)
  </code></pre>
  
  <p>How can I get a new numpy array with only the values in a where the same index in <code>f</code> is True? In my case: <code>[2, 5]</code>.</p>
  
  <p>According to the accepted solution (with different values):</p>
  
  <pre><code>&gt;&gt;&gt; a = numpy.array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])
  &gt;&gt;&gt; b = numpy.array([True, False, True, False, True, False, True, False, True, False])
  &gt;&gt;&gt; a[b]
  array([1, 3, 5, 7, 9])
  </code></pre>