title: How to create a new column for transposed data
body: <p>I'm attempting to transpose a row into a new column using the pandas dataframe. Visit ID is the unique identifier. I used df.pivot and df.melt but df.melt seems to do the opposite. I'm pretty new to Python and I gave it a start but I'm pretty lost.
  Any suggestions?</p>
  <p><strong>Current input:</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Visit ID</th>
  <th>DX Code</th>
  <th>Insurance</th>
  <th>Primary or Secondary</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1</td>
  <td>123</td>
  <td>Aetna</td>
  <td>Primary</td>
  </tr>
  <tr>
  <td style="text-align: left;">1</td>
  <td>234</td>
  <td>Affinity</td>
  <td>Secondary</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td>456</td>
  <td>VNS</td>
  <td>Secondary</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td>789</td>
  <td>Medicare</td>
  <td>Primary</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Desired Output:</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Visit ID</th>
  <th>DX Code</th>
  <th>DX Code2</th>
  <th>Primary</th>
  <th>Secondary</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>123</td>
  <td>234</td>
  <td>Aetna</td>
  <td>Affinity</td>
  </tr>
  <tr>
  <td>2</td>
  <td>456</td>
  <td>789</td>
  <td>Medicare</td>
  <td>VNS</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>import pandas as pd
  
  df = pd.read_excel(r'C:\Users\TEST.xlsx', sheet_name = 'Sheet1')
  
  # pivot = df.pivot(index='Visit ID', columns='DX Code', values = 'DX ID')
  # print(pivot)
  
  # melt = df.melt(value_name='DX Code', var_name='DX Code2')
  # print(melt)
  </code></pre>