title: python pandas groupby then count rows satisfying condition
body: <p>i am trying to do a groupby on the <code>id column</code> such that i can show the number of rows in col1 that is equal to 1.</p>
  
  <p>df:</p>
  
  <pre><code>id col1 col2 col3
  a   1     1    1
  a   0     1    1
  a   1     1    1
  b   1     0    1
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>df.groupby(['id'])[col1].count()[1]
  </code></pre>
  
  <p>output i got was 2. It didnt show me the values from other <code>ids</code> like b. </p>
  
  <p>i want:</p>
  
  <pre><code>id col1
  a   2    
  b   1 
  </code></pre>
  
  <p>if possible can the total rows per id also be displayed as a new column?</p>
  
  <p>example:</p>
  
  <pre><code>id col1 total
  a   2    3
  b   1    1
  </code></pre>