Numpy delete multiple rows matching criteria
<p>I have a numpy array of folowing structure</p>

<pre><code>sb = np.genfromtxt(open('HomePage/TodayList.txt', 'rb'),
                   delimiter=',', skiprows=0,
                   dtype=[('DataBase', np.str_, 16), ('Mode', np.str_, 16),
                          ('SMB', np.str_, 16),('Desc', np.str_, 128), 
                          ('Res', np.str_, 16), ('RightCnt', np.float64), 
                          ('PercentCnt', np.float64), ('ModelType', np.float64)])
</code></pre>

<p>The 6th column <code>'PercentCnt'</code> which can be accessed by name <code>'PercentCnt'</code> contains numbers from 0 to 50
the 7th column <code>'ModelType'</code> contains numbers from 0 to 5 so i need to remove or delete array rows which match these criteria <code>'PercentCnt'&lt;50</code> and <code>'ModelType'&lt;2</code>.</p>

<p>The condition</p>

<pre><code>sb['PercentCnt'] &gt;= 50
</code></pre>

<p>is the condition for <em>keeping</em> things on this column, and the condition</p>

<pre><code>sb['ModelType'] &gt;= 2
</code></pre>

<p>is the same for the other column.</p>

<p>You can combine these with <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.logical_and.html" rel="nofollow"><code>np.logical_and</code></a>:</p>

<pre><code>keep = np.logical_and(sb['PercentCnt'] &gt;= 50, sb['ModelType'] &gt;= 2)
</code></pre>

<p>Finally, just keep the rows you wish to keep:</p>

<pre><code>sb[keep]
</code></pre>

python numpy