擅长:python、mysql、java
<p>您可以使用<code>np.logical_and.reduce</code>和{<cd2>}来处理多个单词。在</p>
<p><code>df[np.logical_and.reduce([df['ids'].str.contains(w) for w in ['ball', 'field']])]</code></p>
<pre><code>In [96]: df
Out[96]:
ids
0 ball is field
1 ball is wa
2 doll is field
In [97]: df[np.logical_and.reduce([df['ids'].str.contains(w) for w in ['ball', 'field']])]
Out[97]:
ids
0 ball is field
</code></pre>