title: Pivoting MultiIndex Data
body: <p>I have a MultiIndex pandas dataframe that looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Ig19U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ig19U.png" alt="Input"></a></p>
  
  <p>I want the different quarters as rows instead of hierarchial columns i.e. a long format instead of this wide one. Something like this (output need not be a multindex):</p>
  
  <p><a href="https://i.stack.imgur.com/HDQij.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HDQij.png" alt="output"></a></p>
  
  <p>How can I do this in Pandas?</p>
  
  <p>Edit:</p>
  
  <p>Sample input file as requested:</p>
  
  <p><a href="https://drive.google.com/file/d/1unIsKfplAy9I46Heyu5jJ6oK3DJm0hQV/view?usp=sharing" rel="nofollow noreferrer">rbi_credits_data.xlsx</a></p>
  
  <p>Sample Data(Pandas):</p>
  
  <pre><code>cols = pd.MultiIndex(levels=[['Center_Details', '2017-18:Q2', '2017-18:Q1'],
                         ['State', 'District', 'Center', 'Offices', 'Deposit', 'Credit']],
                 labels=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
                         [0, 1, 2, 3, 4, 5, 3, 4, 5]])
  data = [['JAMMU &amp; KASHMIR', 'KUPWARA', 'Drug Mulla (CT)', '3', '500', '600', '4', '500', '600'], 
      ['JAMMU &amp; KASHMIR', 'LEH LADAKH', 'Chuglamsar (CT)', '3', '500', '600', '4', '500', '600'], 
      ['PUNJAB', 'PATHANKOT', 'Mamun (CT)', '3', '500', '600', '4', '500', '600'], 
      ['PUNJAB', 'GURDASPUR', 'TIBRI', '3', '500', '600', '4', '500', '600']]
  df = pd.DataFrame(data=data, columns=cols)
  </code></pre>