Finding specific strings within a column and finding the max corresponding to that string
<p>I was wondering: <br></p>

<p>1.) how do I find a specific string in a column <br>
2.) given that string, how would I find it's corresponding max  <br>
3.) How do I count the number of strings for each row in that column</p>

<p>I have a csv file called sports.csv</p>

<pre><code> import pandas as pd
 import numpy as np

#loading the data into data frame
X = pd.read_csv('sports.csv')
</code></pre>

<p>the two columns of interest are the <code>Totals</code> and <code>Gym</code> column:</p>

<pre><code> Total  Gym
40  Football|Baseball|Hockey|Running|Basketball|Swimming|Cycling|Volleyball|Tennis|Ballet
37  Baseball|Tennis
61  Basketball|Baseball|Ballet
12  Swimming|Ballet|Cycling|Basketball|Volleyball|Hockey|Running|Tennis|Baseball|Football
78  Swimming|Basketball
29  Baseball|Tennis|Ballet|Cycling|Basketball|Football|Volleyball|Swimming
31  Tennis
54  Tennis|Football|Ballet|Cycling|Running|Swimming|Baseball|Basketball|Volleyball
33  Baseball|Hockey|Swimming|Cycling
17  Football|Hockey|Volleyball
</code></pre>

<p>Notice that the <code>Gym</code> column has multiple strings for each corresponding sport.I'm trying to find a way to find all of the gyms that have Baseball and find the one with the max total. However, I'm only interested in gyms that have at least two other sports i.e. I wouldn't want to consider:</p>

<pre><code>  Total   Gym
  37    Baseball|Tennis
</code></pre>