title: Create multiple DataFrames from one pandas DataFrame by grouping by column values
body: <p>So I have the following dataframe, but with a valuable amount of rows(100, 1000, etc.):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">#</th>
  <th style="text-align: center;">Person1</th>
  <th style="text-align: right;">Person2</th>
  <th style="text-align: right;">Age</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1</td>
  <td style="text-align: center;">Alex</td>
  <td style="text-align: right;">Maria</td>
  <td style="text-align: right;">20</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td style="text-align: center;">Paul</td>
  <td style="text-align: right;">Peter</td>
  <td style="text-align: right;">20</td>
  </tr>
  <tr>
  <td style="text-align: left;">3</td>
  <td style="text-align: center;">Klaus</td>
  <td style="text-align: right;">Hans</td>
  <td style="text-align: right;">30</td>
  </tr>
  <tr>
  <td style="text-align: left;">4</td>
  <td style="text-align: center;">Victor</td>
  <td style="text-align: right;">Otto</td>
  <td style="text-align: right;">30</td>
  </tr>
  <tr>
  <td style="text-align: left;">5</td>
  <td style="text-align: center;">Gerry</td>
  <td style="text-align: right;">Justin</td>
  <td style="text-align: right;">30</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Problem:</strong></p>
  <p>Now I want to print separate dataframes, which contain all people, that visit the same age, so the output should look like this:</p>
  <p>DF1:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">#</th>
  <th style="text-align: left;">Person1</th>
  <th style="text-align: right;">Person2</th>
  <th style="text-align: right;">Age</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1</td>
  <td style="text-align: left;">ALex</td>
  <td style="text-align: right;">Maria</td>
  <td style="text-align: right;">20</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td style="text-align: left;">Paul</td>
  <td style="text-align: right;">Peter</td>
  <td style="text-align: right;">20</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>DF2:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">#</th>
  <th style="text-align: left;">Person1</th>
  <th style="text-align: right;">Person2</th>
  <th style="text-align: right;">Age</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">3</td>
  <td style="text-align: left;">Klaus</td>
  <td style="text-align: right;">Hans</td>
  <td style="text-align: right;">30</td>
  </tr>
  <tr>
  <td style="text-align: left;">4</td>
  <td style="text-align: left;">Victor</td>
  <td style="text-align: right;">Otto</td>
  <td style="text-align: right;">30</td>
  </tr>
  <tr>
  <td style="text-align: left;">5</td>
  <td style="text-align: left;">Gerry</td>
  <td style="text-align: right;">Justin</td>
  <td style="text-align: right;">30</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I've tried this with the following functions:</p>
  <p><strong>Try1:</strong></p>
  <pre><code>def groupAge(data):
      x = -1
      for x in range(len(data)):
          #q = len(data[data[&quot;Age&quot;] == data.loc[x, &quot;Age&quot;]])
  
          b = data[data[&quot;Age&quot;] == data.loc[x,&quot;Age&quot;]]
          x = x + 1
          print(b,x)
  
  
      return  b
  </code></pre>
  <p><strong>Try2:</strong></p>
  <pre><code>def groupAge(data):
      x = 0
  
      for x in range(len(data)):
  
          q = len(data[data[&quot;Age&quot;] == data.loc[x, &quot;Age&quot;]])
          x = x + 1
  
          for k in range(0,q,q):
              b = data[data[&quot;Age&quot;] == data.loc[k,&quot;Age&quot;]]
              print(b)
  
          return  b
  </code></pre>
  <p>Neither of them produced the right output. Try1 prints a few groups, and all of them twice, but doesn't go through the entire dataframe and Try2 only prints the first Age &quot;group&quot;, also twice.</p>
  <p>I can't identify firstly why it always prints the output two times, neither why it doesn't work through the entire dataframe.</p>
  <p>Can anyone help?</p>