title: Python : Pandas pivot table for multiple columns at once which has duplicate values
body: <p>have a pandas dataframme with columns name , school and marks</p>
  <pre><code>name  school  marks
  
  tom     HBS     55
  tom     HBS     55
  tom     HBS     14
  mark    HBS     28
  mark    HBS     19
  lewis   HBS     88
  </code></pre>
  <p>How to transpose and convert into like this</p>
  <pre><code>name  school  marks_1 marks_2 marks_3
  
  tom     HBS     55     55       14
  mark    HBS     28     19
  lewis   HBS     88
  </code></pre>
  <p>tried this:</p>
  <pre><code>df = df.pivot_table(index='name', values='marks', columns='school') \
      .reset_index() \
      .rename_axis(None, axis=1)
  
  print(df)
  </code></pre>
  <pre><code>df = df.pivot('name','marks','school')
  </code></pre>
  <p>checked these links</p>
  <pre><code>https://stackoverflow.com/questions/22798934/pandas-long-to-wide-reshape-by-two-variables
  https://stackoverflow.com/questions/62391419/pandas-group-by-and-convert-rows-into-multiple-columns
  https://stackoverflow.com/questions/60698109/pandas-multiple-rows-to-single-row-with-multiple-columns-on-2-indexes
  </code></pre>
  <p>getting this error due to duplicate values. how to handle if duplicate exists and we have to keep them</p>
  <pre><code>ValueError: Index contains duplicate entries, cannot reshape
  </code></pre>