title: Conditional groupby pandas
body: <p>I have a dataframe:</p>
  
  <pre><code>df = pd.DataFrame({'dates':['2015-01-01','2015-01-02','2015-01-03','2015-01-03','2015-01- 02','2015-01-02','2015-01-01'],'myvals':[1,2,3,3,4,4,3]})
  </code></pre>
  
  <p>I want to count along with group by like:<code>df.groupby('dates')['myval'].transform('nunique')</code></p>
  
  <p>But I want to perform nunique with a condition only when <code>myval=3</code></p>
  
  <p>Desired Output:</p>
  
  <pre><code>dates        myvals
  2015-01-01   1
  2015-01-02   0
  2015-01-03   2
  2015-01-03   2
  2015-01-02   0
  2015-01-02   0
  2015-01-01   1
  </code></pre>
  
  <p>How can I modify the code in that case. </p>
  
  <p>Thanks!!</p>