title: Pandas: Group by a column that meets a condition
body: <p>I have a data set with three colums: rating , breed, and dog.</p>
  
  <pre><code>import pandas as pd
  dogs = {'breed': ['Chihuahua', 'Chihuahua', 'Dalmatian', 'Sphynx'],
          'dog': [True, True, True, False],
          'rating': [8.0, 9.0, 10.0, 7.0]}
  
  df = pd.DataFrame(data=dogs)
  </code></pre>
  
  <p>I would like to calculate the <strong>mean</strong> rating per breed where dog is True. This would be the expected:</p>
  
  <pre><code>  breed     rating
  0 Chihuahua 8.5   
  1 Dalmatian 10.0  
  </code></pre>
  
  <p>This has been my attempt:</p>
  
  <pre><code>df.groupby('breed')['rating'].mean().where(dog == True)
  </code></pre>
  
  <p>And this is the error that I get:</p>
  
  <pre><code>NameError: name 'dog' is not defined
  </code></pre>
  
  <p>But when I try add the <code>where</code> condition I only get errors. Can anyone advise a solution? TIA</p>