title: Python Pandas Dataframe GroupBy Size based on condition
body: <p>I have a dataframe 'df' that looks like this:</p>
  
  <pre><code>id  date1   date2
  1   11/1/2016   11/1/2016
  1   11/1/2016   11/2/2016
  1   11/1/2016   11/1/2016
  1   11/1/2016   11/2/2016
  1   11/2/2016   11/2/2016
  2   11/1/2016   11/1/2016
  2   11/1/2016   11/2/2016
  2   11/1/2016   11/1/2016
  2   11/2/2016   11/2/2016
  2   11/2/2016   11/2/2016
  </code></pre>
  
  <p>What I would like to do is to groupby the id, then get the size for each id where date1=date2.  The result should look like:</p>
  
  <pre><code>id  samedate    count
  1   11/1/2016    2 
  1   11/2/2016    1 
  2   11/1/2016    2 
  2   11/2/2016    2 
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>gb=df.groupby(id').apply(lambda x: x[x.date1== x.date2]['date1'].size())
  </code></pre>
  
  <p>And get this error:</p>
  
  <pre><code>TypeError: 'int' object is not callable
  </code></pre>
  
  <p>You could certainly flag each instance where the date1 and date2 are equal, then count those flags for each id by each samedate, but I have to believe there is a groupby option for this.</p>