title: Pandas: Mean of columns with the same names
body: <p>I have a dataframe with columns like:</p>
  
  <pre><code>['id','name','foo1', 'foo1', 'foo1', 'foo2','foo2', 'foo3']
  </code></pre>
  
  <p>I would like to get a new dataframe where columns sharing the same name are averaged:</p>
  
  <pre><code>['id','name','foo1', 'foo2','foo3']
  </code></pre>
  
  <p>Here column foo1 would be the average of the three columns named foo1 in the original dataframe, foo2 would be the average of the two columns named foo2 and foo3 would be just foo3</p>
  
  <p>Note: id and name are not numeric and I have to keep them. </p>