title: pandas: generate and plot average
body: <p>I have a pandas dataframe like:</p>
  
  <pre><code>In [61]: df = DataFrame(np.random.rand(3,4), index=['art','mcf','mesa'],
                          columns=['pol1','pol2','pol3','pol4'])
  
  In [62]: df
  Out[62]: 
            pol1      pol2      pol3      pol4
  art   0.661592  0.479202  0.700451  0.345085
  mcf   0.235517  0.665981  0.778774  0.610344
  mesa  0.838396  0.035648  0.424047  0.866920
  </code></pre>
  
  <p>and I want to generate a row with the average for the policies across benchmarks and then plot it.</p>
  
  <p>Currently, the way I do this is:</p>
  
  <pre><code>df = df.T
  df['average'] = df.apply(average, axis=1)
  df = df.T
  df.plot(kind='bar')
  </code></pre>
  
  <p>Is there an elegant way to avoid the double transposition?</p>
  
  <p>I tried:</p>
  
  <pre><code>df.append(DataFrame(df.apply(average)).T)
  df.plot(kind='bar')
  </code></pre>
  
  <p>This will append the correct values but does not update the index properly and the graph is messed up.</p>
  
  <p>A clarification. The result of the code with the double transposition is this: <img src="https://i.stack.imgur.com/3EU87.png" alt="enter image description here"> 
  This is what I want. To show both the benchmarks and the average of the policies, not just the average. I was just curious if I can do it better. </p>
  
  <p>Note that the legend is usually messed up. For a fix: </p>
  
  <pre><code>ax = df.plot(kind='bar')
  ax.legend(patches, list(df.columns), loc='best')
  </code></pre>