title: Python filter numpy array based on mask array
body: <p>Let's say I have an data numpy array of length N, and a bit mask array of length N.</p>
  <pre><code>data = [1,2,3,4,5,6,7,8,9,0]
  mask = [0,1,0,1,0,1,0,1,0,1]
  </code></pre>
  <p>Is there a loopless numpy way to create a new array based off data, such that it takes all the entries of data if and only if masks[i] != 0? Like so:</p>
  <pre><code>func(data, mask) = [2,4,6,8,0]
  </code></pre>
  <p>Or equivalently in loop notation:</p>
  <pre><code>ans = []
  for idx in range(mask):
      if mask[idx]:
          ans.append(data[idx])
  ans = numpy.array(ans)
  </code></pre>
  <p>Thanks!</p>