title: Pandas DataFrame: Calculate percentage difference between rows?
body: <p>I have a year wise dataframe with each year has three parameters <code>year</code>,<code>type</code> and <code>value</code>. I'm trying to calculate percentage of taken vs empty. For example year <code>2014</code> has total of <code>50 empty</code> and <code>50 taken</code> - So 50% in empty and 50% in taken as shown in final_df</p>
  <p>df</p>
  <pre><code>    year     type          value
              
  0     2014  Total          100
  1     2014  Empty           50
  2     2014  Taken           50
  3     2013  Total          2000
  4     2013  Empty          100
  5     2013  Taken          1900
  6     2012  Total          50
  7     2012  Empty          45
  8     2012  Taken           5
  </code></pre>
  <p>Final df</p>
  <pre><code>    year    Empty          Taken
              
  0   2014    50             50 
  0   2013    ...            ...    
  0   2012    ...            ... 
  </code></pre>
  <p>Should i shift cells up and do the percentage calculate or any other method?</p>