title: python pandas: pivoting columns to rows
body: <p>I have a table like:</p>
  
  <pre><code>country | name  | medals_won | year
  -----------------------------------
  US      | sarah |      1     | 2010
  US      | sarah |      2     | 2011
  US      | sarah |      5     | 2015
  US      | alice |      3     | 2010
  US      | alice |      4     | 2012
  US      | alice |      1     | 2015
  AU      | jones |      2     | 2013
  AU      | jones |      8     | 2015
  </code></pre>
  
  <p>I want it like:</p>
  
  <pre><code>country | name  | 2010 | 2011 | 2012 | 2013 | 2014 | 2015
  ---------------------------------------------------------
  US      | sarah | 1    | 2    | 0    | 0    | 0    | 5
  US      | alice | 3    | 0    | 4    | 0    | 0    | 1
  AU      | jones | 0    | 0    | 0    | 2    | 0    | 8
  </code></pre>
  
  <p>I've tinkered with <code>df.apply</code>, or even brute-force iteration, but you can probably guess that the tricky part is that these row values aren't strictly sequential, so this isn't a simple transpose operation (nobody won any medals in 2014, for e.g., but I want the resulting table to show that in a column full of zeros).</p>