<pre><code>In [82]: d
Out[82]:
A B C D
0 John Doe 45 True False
1 Jane Smith 32 False False
2 Alan Holmes 55 False True
3 Eric Lamar 29 True True
</code></pre>
<p><strong>解决方案1:</strong></p>
<pre><code>In [83]: d.loc[d.C | d.D]
Out[83]:
A B C D
0 John Doe 45 True False
2 Alan Holmes 55 False True
3 Eric Lamar 29 True True
</code></pre>
<p><strong>解决方案2:</strong></p>
<pre><code>In [94]: d[d[['C','D']].any(1)]
Out[94]:
A B C D
0 John Doe 45 True False
2 Alan Holmes 55 False True
3 Eric Lamar 29 True True
</code></pre>
<p><strong>解决方案3:</strong></p>
<pre><code>In [95]: d.query("C or D")
Out[95]:
A B C D
0 John Doe 45 True False
2 Alan Holmes 55 False True
3 Eric Lamar 29 True True
</code></pre>
<p>PS如果您将解决方案更改为:</p>
<pre><code>df[(df['C']==True) | (df['D']==True)]
</code></pre>
<p>也会有用的</p>
<p><a href="https://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="noreferrer">Pandas docs - boolean indexing</a></p>
<hr/>
<blockquote>
<p><a href="https://stackoverflow.com/questions/46207530/filtering-pandas-dataframe-with-multiple-boolean-columns/46207540?noredirect=1#comment101065544_46207540">why we should NOT use "PEP complaint" <code>df["col_name"] is True</code> instead of <code>df["col_name"] == True</code>?</a></p>
</blockquote>
<pre><code>In [11]: df = pd.DataFrame({"col":[True, True, True]})
In [12]: df
Out[12]:
col
0 True
1 True
2 True
In [13]: df["col"] is True
Out[13]: False # <----- oops, that's not exactly what we wanted
</code></pre>