title: Mean of repeated columns in pandas dataframe
body: <p>I have a dataframe with repeated column names which account for repeated measurements.</p>
  
  
  
  <p></p>
  
  <pre><code>df = pd.DataFrame({'A': randn(5), 'B': randn(5)})
  df2 = pd.DataFrame({'A': randn(5), 'B': randn(5)})
  df3 = pd.concat([df,df2], axis=1)
  df3
        A         B         A         B
  0 -0.875884 -0.298203  0.877414  1.282025
  1  1.605602 -0.127038 -0.286237  0.572269
  2  1.349540 -0.067487  0.126440  1.063988
  3 -0.142809  1.282968  0.941925 -1.593592
  4 -0.630353  1.888605 -1.176436 -1.623352
  </code></pre>
  
  <p> </p>
  
  <p>I'd like to take the mean of cols 'A's and 'B's such that the dataframe shrinks to</p>
  
  <pre><code>      A         B    
  0  0.000765  0.491911
  1  0.659682  0.222616
  2  0.737990  0.498251
  3  0.399558 -0.155312
  4 -0.903395  0.132627
  </code></pre>
  
  <p>If I do the typical </p>
  
  <pre><code>df3['A'].mean(axis=1)
  </code></pre>
  
  <p>I get a Series (with no column name) and I should then build a new dataframe with the means of each col group. Also the .groupby() method apparently doesn't allow you to group by column name, but rather you give the columns and it sorts the indexes. Is there a fancy way to do this?</p>
  
  <p><em>Side question: why does</em></p>
  
  <pre><code>df = pd.DataFrame({'A': randn(5), 'B': randn(5), 'A': randn(5), 'B': randn(5)})
  </code></pre>
  
  <p><em>not generate a 4-column dataframe but merges same-name cols?</em></p>