title: Assign groupby-apply result to parent dataframe
body: <p>I have the following data frame: </p>
  
  <pre><code>df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar','foo', 'bar', 'foo', 'foo'],
                     'B' : ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'],
                     'C' : np.random.randn(8),
                     'D' : np.random.randn(8)})
  
      A   B   C   D
  0   foo one 0.478183    -1.267588
  1   bar one 0.555985    -2.143590
  2   foo two -1.592865   1.251546
  3   bar three   0.174138    -0.708198
  4   foo two 0.302215    -0.219041
  5   bar two -0.034550   -0.965414
  6   foo one 1.310828    -0.388601
  7   foo three   0.357659    -1.610443
  </code></pre>
  
  <p>I'm trying to add another column which will be a normalized version of column <strong>C</strong> over partition by A: </p>
  
  <pre><code>normed = df.groupby('A').apply(lambda x: (x['C']-min(x['C']))/(max(x['C'])-min(x['C'])))
  
  A     
  bar  1    0.000000
       3    0.033396
       5    1.000000
  foo  0    1.000000
       2    0.413716
       4    0.000000
       6    0.441061
       7    0.357787
  </code></pre>
  
  <p>Finally I want to join this result back to df (using advice from the <a href="https://stackoverflow.com/questions/12200693/python-pandas-how-to-assign-groupby-operation-results-back-to-columns-in-parent">similar question</a>): </p>
  
  <pre><code>df.join(normed, on='A', rsuffix='_normed')
  </code></pre>
  
  <p>However, I get an error: </p>
  
  <blockquote>
    <p>ValueError: len(left_on) must equal the number of levels in the index
    of "right"</p>
  </blockquote>
  
  <p>How can I add <code>normed</code> result back to dataframe <code>df</code>?</p>