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>You can find all rows matching your criteria by use of a column-wise comparison for <code>PercentCnt</code> and <code>ModelType</code> and connection using <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.logical_and.html" rel="nofollow"><code>np.logical_and</code></a>. Doing that, you  actually copy all other rows rather than to delete the ones you wanted to get rid of, but the effect is the same.</p>

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

python numpy