title: Masking numpy arrays to select specific rows, based on another boolean array
body: <p>Suppose that I have an array like this:</p>
  <pre><code>my_arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
  </code></pre>
  <p>or a 2D array like:</p>
  <pre><code>my_arr = np.array([[1, 1, 11], [2, 1, 0], [3, 3, -1], ..., [10, 9, 0]])
  </code></pre>
  <p>And I define an array like</p>
  <p>mask_arr = ([1, 1, 0, 0, 1, 0, 1, 1, 0, 1])</p>
  <p>What I want to do from the mask array is to obtain a new array which is consisted of rows, wherein the mask_arr of their index, the element is equal to &quot;1&quot;.</p>
  <p>For example, the result of the first array would be like:</p>
  <pre><code>[1, 2, 0, 0, 5, 0, 7, 8, , 10]
  </code></pre>
  <p>I tried</p>
  <pre><code>my_arr[my_mask]
  </code></pre>
  <p>But it didn't work. Is there any solution without wanting to write a for loop to do that?</p>
  <p>Thank you in advance</p>