title: Pandas groupby - when column is a certain value
body: <p>For the following table:</p>
  <p><a href="https://i.stack.imgur.com/0oP9t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0oP9t.png" alt="enter image description here" /></a></p>
  <p>I would like to use the groupby function with 'number_of_horses' and show a count for the 'TRUE' values in the 'winner' column.</p>
  <p>Using Python-Pandas, I have tried:</p>
  <p>INPUT:</p>
  <pre class="lang-py prettyprint-override"><code>df.groupby('number_of_horses').winner.count()
  </code></pre>
  <p>OUTPUT:</p>
  <p><a href="https://i.stack.imgur.com/zfb0b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zfb0b.png" alt="enter image description here" /></a></p>
  <p>The table above is not the desired output.</p>
  <p>The desired output is:</p>
  <p><a href="https://i.stack.imgur.com/7MBkh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7MBkh.png" alt="enter image description here" /></a></p>
  <p>Note that the 'winner' column is only counted when the value is TRUE.</p>