Filtering a multiindex dataframe based on column values dropping all rows inside level
<p>I am trying to filter a DataFrame based on one or more values. Here is an example CSV:</p>

<pre><code>AlignmentId,TranscriptId,classifier,value
ENSMUST00000025010-1,ENSMUST00000025010,AlnCoverage,0.99612
ENSMUST00000025010-1,ENSMUST00000025010,AlnIdentity,0.93553
ENSMUST00000025010-1,ENSMUST00000025010,Badness,0.06749
ENSMUST00000025014-1,ENSMUST00000025014,AlnCoverage,1.0
ENSMUST00000025014-1,ENSMUST00000025014,AlnIdentity,0.96382
ENSMUST00000025014-1,ENSMUST00000025014,Badness,0.03618
</code></pre>

<p>And when loaded:</p>

<pre><code>&gt;&gt;&gt; df = pd.read_csv('tmp.csv', index_col=['AlignmentId', 'TranscriptId'])
&gt;&gt;&gt; df
                                          classifier    value
AlignmentId          TranscriptId
ENSMUST00000025010-1 ENSMUST00000025010  AlnCoverage  0.99612
                     ENSMUST00000025010  AlnIdentity  0.93553
                     ENSMUST00000025010      Badness  0.06749
ENSMUST00000025014-1 ENSMUST00000025014  AlnCoverage  1.00000
                     ENSMUST00000025014  AlnIdentity  0.96382
                     ENSMUST00000025014      Badness  0.03618
</code></pre>

<p>I want to drop every <code>AlignmentId</code> group that fail a series of <code>classifiers</code>. For this example, lets say that I want to drop <code>ENSMUST00000025010</code> because <code>AlnCoverage &lt; 1.0</code>. Thus, I want to end up with this dataframe:</p>

<pre><code>ENSMUST00000025014-1 ENSMUST00000025014  AlnCoverage  1.00000
                     ENSMUST00000025014  AlnIdentity  0.96382
                     ENSMUST00000025014      Badness  0.03618
</code></pre>

<p>How can I do so? </p>

<p>try this:</p>

<pre><code>In [169]: df = df.drop(df[(df.classifier=='AlnCoverage') &amp; (df.value &lt; 1)].index)

In [170]: df
Out[170]:
                                          classifier    value
AlignmentId          TranscriptId
ENSMUST00000025014-1 ENSMUST00000025014  AlnCoverage  1.00000
                     ENSMUST00000025014  AlnIdentity  0.96382
                     ENSMUST00000025014      Badness  0.03618
</code></pre>

python pandas dataframe multi-index