title: Search and Push n elements into custom_arr from x_arr where condition with y_arr
body: <p>Sorry if the title is a bit confusing, I don't know how else can I make this question more specific.</p>
  <p>I am trying to create an Adaboost implementation in Python, I am using the MNIST from Keras datasets.</p>
  <p>Currently, I am just trying to create a training array for a weak threshold that classifies the &quot;0&quot; number images.</p>
  <p>For that, I need to create an array, half of it being just images of &quot;0&quot;, and the other half being any other random number.</p>
  <p>Currently, I have 2 arrays, <code>x_train</code>: an array that contains the pictures and <code>y_train</code>: an array that contains the tag, that way we can check if, for example, <code>x_train[i]</code> is a picture of the number &quot;0&quot; if <code>y_train[i] == 0</code>.</p>
  <p><a href="https://i.stack.imgur.com/zfFZD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zfFZD.png" alt="enter image description here" /></a></p>
  <p>So, I want to know if there's an automated way of doing that using NumPy, to grab elements from an array using a condition applied to another array.</p>
  <p>Basically: Grab n elements and push into custom_array from x_array[i] if y_array[i] == 0 , and, grab n elements and push into custom_array from x_array[i] if y_array[i] != 0.</p>
  <p>Best regards.</p>