title: How to create a multi-index in Pandas
body: <h1>Question</h1>
  
  <p>There are two questions that look similar but they're not the same question: <a href="https://stackoverflow.com/questions/10373660/converting-a-pandas-groupby-object-to-dataframe">here</a> and <a href="https://stackoverflow.com/questions/13582449/convert-dataframegroupby-object-to-dataframe-pandas">here</a>. They both call a method of <code>GroupBy</code>, such as <code>count()</code> or <code>aggregate()</code>, which I know returns a <code>DataFrame</code>. What I'm asking is how to convert the <code>GroupBy</code> (class <code>pandas.core.groupby.DataFrameGroupBy</code>) object itself into a <code>DataFrame</code>. I'll illustrate below.</p>
  
  <h1>Example</h1>
  
  <p>Construct an example <code>DataFrame</code> as follows.</p>
  
  <pre><code>data_list = []
  for name in ["sasha", "asa"]:
      for take in ["one", "two"]:
          row = {"name": name, "take": take, "score": numpy.random.rand(), "ping": numpy.random.randint(10, 100)}
          data_list.append(row)
  data = pandas.DataFrame(data_list)
  </code></pre>
  
  <p>The above <code>DataFrame</code> should look like the following (with different numbers obviously).</p>
  
  <pre><code>    name  ping     score take
  0  sasha    72  0.923263  one
  1  sasha    14  0.724720  two
  2    asa    76  0.774320  one
  3    asa    71  0.128721  two
  </code></pre>
  
  <p>What I want to do is to group by the columns "name" and "take" (in that order), so that I can get a <code>DataFrame</code> indexed by the multiindex constructed from the columns "name" and "take", like below.</p>
  
  <pre><code>               score  ping
   name take        
  sasha  one  0.923263    72
         two  0.724720    14
    asa  one  0.774320    76
         two  0.128721    71
  </code></pre>
  
  <p>How do I achieve that? If I do <code>grouped = data.groupby(["name", "take"])</code>, then <code>grouped</code> is a <code>pandas.core.groupby.DataFrameGroupBy</code> instance. What is the correct way of doing this?</p>