title: how to Stack columns in Python
body: <p>I have a two columns and multiple rows in an excel sheet by using python i want to stack the data(similar way how we do in minitab) </p>
  
  <p>This is how my data looks like </p>
  
  <pre><code>Adults--------------------------------&gt;Children
  
  Did Not Purchase------------------&gt;Did Not Purchase
  
  Did Not Purchase------------------&gt;Purchased
  
  Did Not Purchase-------------------&gt;Did Not Purchase
  
  Did Not Purchase-------------------&gt;Purchased
  
  Did Not Purchase------------------&gt;Did Not Purchase
  
  Did Not Purchase-------------------&gt;Did Not Purchase
  
  Did Not Purchase--------------------&gt;Did Not Purchase
  
  Did Not Purchase-------------------&gt;Purchased
  
  Did Not Purchase-------------------&gt;Did Not Purchase
  
  Did Not Purchase-------------------&gt;Did Not Purchase
  
  Did Not Purchase-------------------&gt;Did Not Purchase
  
  Did Not Purchase--------------------&gt;Did Not Purchase
  
  Purchased--------------------------&gt;Did Not Purchase
  
  Purchased--------------------------&gt;Did Not Purchase
  
  Purchased--------------------------&gt;Did Not Purchase
  
  Did Not Purchase--------------------&gt;Did Not Purchase
  
  Did Not Purchase--------------------&gt;Did Not Purchase
  
  Did Not Purchase---------------------&gt;Did Not Purchase
  
  Did Not Purchase--------------------&gt;Did Not Purchase
  </code></pre>
  
  <p>I have tried by using stack function this but what happened is data is storing in index values </p>
  
  <pre><code>stacked_df=two_prop_test.stack()
  stacked_df
  </code></pre>
  
  <p><strong>Expected Result</strong></p>
  
  <pre><code>Person--------------                     Icecream   
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults--------------                  Did Not Purchase  
  
  Adults----------                  Did Not Purchase  
  
  Adults----------                  Did Not Purchase  
  
  Adults-----------                 Purchased 
  
  Adults------------                Purchased 
  
  Adults----------                  Purchased 
  
  Adults-----------                 Did Not Purchase  
  
  Adults-----------                 Did Not Purchase  
  
  Adults-----------                 Did Not Purchase  
  
  Children---------         Did Not Purchase  
  
  Children---------         Purchased 
  
  Children---------         Did Not Purchase  
  
  Children---------         Purchased 
  
  Children---------         Did Not Purchase  
  
  Children---------         Did Not Purchase  
  
  Children----------        Did Not Purchase  
  
  Children---------         Purchased 
  
  Children--------          Did Not Purchase  
  
  Children---------        Did Not Purchase   
  
  Children --------        Did Not Purchase   
  
  Children--------         Did Not Purchase   
  
  Children---------        Did Not Purchase   
  
  Children--------         Did Not Purchase   
  
  Children---------        Did Not Purchase   
  
  Children---------        Did Not Purchase   
  
  Children--------         Did Not Purchase   
  
  Children--------         Did Not Purchase
  </code></pre>