title: Sorting month columns in pandas pivot_table
body: <p>I have a dataset made up of 4 columns, a numerator denominator, country, and month. I am pivoting it to get months as columns, country as index, and values as <code>sum(numerator)/sum(denominator)</code>. The only problem I get is that my columns are all out of order. How can I sort the columns so earlier months appear first? I tried <code>table = table.sort_index(1)</code> with no luck.</p>
  
  <pre><code>table = pd.pivot_table(df, values=['Numerator', 'Denominator'], index='Country',
                  columns=['Month'], aggfunc=np.sum)
  
  table = table['Numerator'] / table['Denominator']
  </code></pre>
  
  <p><em>Edit with full example and data</em>:</p>
  
  <p>Data:</p>
  
  <pre><code>Denominator,Numerator,Country,Month
  10,4,USA,1-Jan
  6,2,USA,1-Jan
  10,1,Canada,1-Jan
  9,2,Canada,1-Jan
  6,4,Canada,1-Feb
  4,3,Canada,1-Feb
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.read_csv('data.csv')
  
  table = pd.pivot_table(df, values=['Numerator', 'Denominator'], index='Country',
                  columns=['Month'], aggfunc=np.sum)
  table = table['Numerator'] / table['Denominator']
  print table
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Month    1-Feb     1-Jan
  Country                 
  Canada     0.7  0.157895
  USA        NaN  0.37500
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>Month    1-Jan     1-Feb
  Country                 
  Canada     0.157895  0.7
  USA        0.37500   NaN
  </code></pre>