title: Panda Pivot - Sort by Column
body: <p>I have data that look like this from a panda pivot table: </p>
  
  <pre><code>df:
      sum
      PrctChange
      Year        2011        2012        2013        2014        2015
      CountryName                 
      Argentina   17.378744   5.750719    7.923327    -0.062792   8.889681
      Belize      0.515086    -1.278683   16.819298   -0.104759   10.539688
      Burundi     0.000000    inf         3.209646    2.165577    6.411365
  </code></pre>
  
  <p>I'm trying to sort it by the 2015 data so that it's listed as Belize, Argentina and Burundi (2015 values in descending order)</p>
  
  <p>I've seen some very relevant and similar questions but they don't seem to work for me</p>
  
  <p><a href="https://stackoverflow.com/questions/37309652/pandas-sort-multiindex-pivot-table">From this question</a>, I tried:</p>
  
  <pre><code>pivot_sorted = df_values(('PrctChange', 2015))
  </code></pre>
  
  <p>and got this error:</p>
  
  <pre><code>KeyError: ('PrctChange', 2015)
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/33590599/pandas-pivot-table-descending-order-python">From this question</a>, I tried:</p>
  
  <pre><code>pivot_sorted = df.sortlevel(["2015"], ascending=[False], sort_remaining=False)
  </code></pre>
  
  <p>I didn't get an error but there was no sorting.</p>
  
  <p>And finally, I tried this</p>
  
  <pre><code>pivot_sorted = df.sort_values(by=(df['2015']), ascending=False,inplace=True)
  </code></pre>
  
  <p>and got this error:</p>
  
  <pre><code>KeyError: '2015'
  </code></pre>
  
  <p>Can anyone please assist? Thank you!</p>