title: pandas add column to groupby dataframe
body: <p>I have this simple dataframe <code>df</code>:</p>
  
  <pre><code>df = pd.DataFrame({'c':[1,1,1,2,2,2,2],'type':['m','n','o','m','m','n','n']})
  </code></pre>
  
  <p>my goal is to count values of <code>type</code> for each <code>c</code>, and then add a column with the size of <code>c</code>. So starting with:</p>
  
  <pre><code>In [27]: g = df.groupby('c')['type'].value_counts().reset_index(name='t')
  
  In [28]: g
  Out[28]: 
     c type  t
  0  1    m  1
  1  1    n  1
  2  1    o  1
  3  2    m  2
  4  2    n  2
  </code></pre>
  
  <p>the first problem is solved. Then I can also:</p>
  
  <pre><code>In [29]: a = df.groupby('c').size().reset_index(name='size')
  
  In [30]: a
  Out[30]: 
     c  size
  0  1     3
  1  2     4
  </code></pre>
  
  <p>How can I add the <code>size</code> column directly to the first dataframe? So far I used <code>map</code> as:</p>
  
  <pre><code>In [31]: a.index = a['c']
  
  In [32]: g['size'] = g['c'].map(a['size'])
  
  In [33]: g
  Out[33]: 
     c type  t  size
  0  1    m  1     3
  1  1    n  1     3
  2  1    o  1     3
  3  2    m  2     4
  4  2    n  2     4
  </code></pre>
  
  <p>which works, but is there a more straightforward way to do this?</p>