title: Transforming pandas dataframe while creating new columns
body: <p>I have a pandas dataframe <code>df</code> which has values as following:</p>
  
  <pre><code>HE  PR  MastLoc Loc     Type    Qty
  1   2   E1      LocA    TC      3
  2   23  E1      LocA    TB      18
  3   17  E1      LocA    TC      11
  3   2   E1      LocB    TC      3
  24  3   E1      LocB    TB      4
  </code></pre>
  
  <p>I want to create the following dataframe <code>df</code> from the above dataframe:</p>
  
  <pre><code>MastLoc Loc     Type    Qty1    PR1   Qty2  PR2   Qty3  PR3  Qty24  PR24
  E1      LocA    TC      3       2                 11    17      
  E1      LocA    TB                    18    23              
  E1      LocB    TC                                3     2       
  E1      LocB    TB                                            4      3
  </code></pre>
  
  <p>New Columns are created by concatenating column names <code>Qty</code> and <code>PR</code> with integer values in column <code>HE</code> (column <code>HE</code> always has integer values). </p>
  
  <p><code>df2</code> basically has rows with unique combination of <code>MastLoc, Loc and Type</code> and all values from columns <code>Qty and HE</code> have been moved to new columns created using integers from column <code>HE</code>.</p>
  
  <p>So, far I have done:</p>
  
  <pre><code>df['colQty'] = ['Qty' + str(x) for x in df['HE'].tolist()]
  df['colPR'] = ['PR' + str(x) for x in df['HE'].tolist()]
  </code></pre>
  
  <p>I am not able to figure a clean way of doing anything further.</p>