title: Pivot Tables in Python have different formatting comparing to Excel
body: <p>Let's say we have a dataframe that looks like this:</p>
  <p><img src="https://i.stack.imgur.com/jqZuh.png" alt="df" /></p>
  <p>I want to use pandas pivot table to format it in this way:</p>
  <p><img src="https://i.stack.imgur.com/282k2.png" alt="Pivot in Excel" />.</p>
  <p>However, <code>df.pivot_table(index='Groupings', columns='columns', values=['value1','value2'])</code> gives me an output that looks like this:</p>
  <p><img src="https://i.stack.imgur.com/crDHy.png" alt="Pivot in Python" /></p>
  <p>Does anyone know how to solve this problem?</p>
  <p>You can use the following code to create the df</p>
  <pre><code>import pandas as pd
  
  data = {&quot;Groupings&quot;: [&quot;item1&quot;, &quot;item1&quot;, &quot;item1&quot;, &quot;item2&quot;, &quot;item2&quot;, &quot;item3&quot;, &quot;item3&quot;],
          &quot;columns&quot;: [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;],
          &quot;value1&quot;: [1,2,3,4,5,6,7],
          &quot;value2&quot;: [11,22,33,44,55,66,77],}
  
  df = pd.DataFrame(data)
  df
  </code></pre>