Replace whole string if it contains substring in pandas
<p>I want to replace all strings that contain a specific substring. So for example if I have this dataframe:</p>

<pre><code>import pandas as pd
df = pd.DataFrame({'name': ['Bob', 'Jane', 'Alice'], 
                   'sport': ['tennis', 'football', 'basketball']})
</code></pre>

<p>I could replace football with the string 'ball sport' like this:</p>

<pre><code>df.replace({'sport': {'football': 'ball sport'}})
</code></pre>

<p>What I want though is to replace everything that contains <code>ball</code> (in this case <code>football</code> and <code>basketball</code>) with 'ball sport'. Something like this:</p>

<pre><code>df.replace({'sport': {'[strings that contain ball]': 'ball sport'}})
</code></pre>