python pandas.Series.str.contains WHOLE WORD
<p>df (Pandas Dataframe) has three rows.</p>

<pre><code>col_name
"This is Donald."
"His hands are so small"
"Why are his fingers so short?"
</code></pre>

<p>I'd like to extract the row that contains "is" and "small".</p>

<p>If I do</p>

<pre><code>df.col_name.str.contains("is|small", case=False)
</code></pre>

<p>Then it catches "His" as well- which I don't want.</p>

<p>Is below query is the right way to catch the whole word in df.series?</p>

<pre><code>df.col_name.str.contains("\bis\b|\bsmall\b", case=False)
</code></pre>

<p>Your way (with /b) didn't work for me. I'm not sure why you can't use the logical operator and (&amp;) since I think that's what you actually want. </p>

<p>This is a silly way to do it, but it works:</p>

<pre><code>mask = lambda x: ("is" in x) &amp; ("small" in x)
series_name.apply(mask)
</code></pre>

python regex pandas dataframe