title: Groupby count only when a certain value is present in one of the column in pandas
body: <p>I have a dataframe similar to the below mentioned database:</p>
  
  <p><code>+------------+-----+--------+
   |    time    | id  | status |
   +------------+-----+--------+
   | 1451606400 | id1 | Yes    |
   | 1451606400 | id1 | Yes    |
   | 1456790400 | id2 | No     |
   | 1456790400 | id2 | Yes    |
   | 1456790400 | id2 | No     |
   +------------+-----+--------+</code></p>
  
  <p>I'm grouping by all the columns mentioned above and i'm able to get the count in a different column named <code>'count'</code> successfully using the below command:</p>
  
  <p><code>df.groupby(['time','id', 'status']).size().reset_index(name='count')</code></p>
  
  <p>But I want the count in the above dataframe only in those rows with <code>status = 'Yes'</code> and rest should be <code>'0'</code></p>
  
  <p>Desired Output:</p>
  
  <p><code>+------------+-----+--------+---------+
   |    time    | id  | status | count   |
   +------------+-----+--------+---------+
   | 1451606400 | id1 | Yes    |       2 |
   | 1456790400 | id2 | Yes    |       1 |
   | 1456790400 | id2 | No     |       0 |
   +------------+-----+--------+---------+</code></p>
  
  <p>I tried to count for <code>status = 'Yes'</code> with the below code:</p>
  
  <p><code>df[df['status']== 'Yes'].groupby(['time','id','status']).size().reset_index(name='count')</code></p>
  
  <p>which obviously gives me those rows with <code>status = 'Yes'</code> and discarded the rest. I want the discarded ones with <code>count = 0</code></p>
  
  <p>Is there any way to get the result?</p>
  
  <p>Thanks in advance!</p>