title: Remove elements from 2D numpy array based on specific value
body: <p>I've got a numpy array with machine learning data, with over 500000 rows.  </p>
  
  <p>It looks like this: </p>
  
  <pre><code>[[1,2,3,4,1,0.3], [1,3,2,4,0,0.9], [3,2,5,4,0,0.8] ...]
  </code></pre>
  
  <p>The first 4 values are parameters, fifth is a class and sixth is probability for class 0.</p>
  
  <p>Problem is, that the data is strongly polarized - there are over 20 times more rows with class 0 than with class 1. This is bad for learning and I need to remove many rows with class 0. But, for best results, I don't want to remove data at random, but like this:</p>
  
  <p>I need to remove rows with highest value on index 5 (probability for class 0) in a loop as long, as there is the same count of rows with 0 and 1 in index 4 (class).</p>
  
  <p>If there is a better solution than a loop, it's fantastic.</p>
  
  <p>This is a little bit complicated, so if you have more questions, feel free to ask.</p>