擅长:python、mysql、java
<p>您可以使用<code>+</code>或<code>apply</code>将所有列连接在一起,然后使用<code>|</code>为regex <code>OR</code>创建具有连接值的<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.contains.html" rel="nofollow noreferrer">^{<cd3>}</a>掩码:</p>
<pre><code>df = df[~(df['Brand']+df['ID']+df['Description']).str.contains('|'.join(keywords))]
</code></pre>
<p>或:</p>
<pre><code>df = df[~df.apply(' '.join, 1).str.contains('|'.join(keywords))]
print (df)
Brand ID Description
1 iPhone DF747 battery
2 Acer KH298 exchanged for a nokia
</code></pre>
<p>如果需要不区分大小写的add<code>case</code>参数:</p>
<pre><code>df = df[~df.apply(' '.join, 1).str.contains('|'.join(keywords), case=False)]
print (df)
Brand ID Description
1 iPhone DF747 battery
</code></pre>