title: Split a CSV file into two equal size groups having a criteria
body: <p>There are many similar questions about this but none were close to my issue. </p>
  
  <p>I would like to split a csv data into two groups of equal length having equal criteria, here is Age. Also, the harder problem could be to combine multiple criteria for the sampling, which could be Age &amp;&amp; Work Experience &amp;&amp; Management Exp, so the outcome is as normalized as possible. </p>
  
  <p>I understand this is an optimization problem of NP (or harder complexity) and perhaps there won't be a closed-form or definite answer, but a close enough would be good.  </p>
  
  <pre><code>import random
  import csv
  import numpy as np
  import pandas as pd
  
  classlist = pd.read_csv('Classlist-Test.csv')
  df = pd.DataFrame(classlist)
  grouped = df.groupby(['Age'])
  
  grouped.sum()
       Work Experience (Yrs)  Management Experience (Yrs)
  Age
  23                       1                            1
  24                      14                            2
  25                      15                            8
  26                      42                           10
  27                      44                            5
  28                      30                            8
  29                      21                            3
  30                      19                            6
  31                      44                           12
  32                      37                            5
  33                      31                            9
  34                      21                           12
  35                      18                            1
  36                      24                            0
  38                      21                            4
  39                      35                           16
  40                      28                           18
  41                      15                            7
  45                      49                           17
  46                      20                           11
  53                      25                           10
  
  &gt;&gt;&gt; df.mean()
  Age                            30.158879
  Work Experience (Yrs)           5.177570
  Management Experience (Yrs)     1.542056
  dtype: float64
  &gt;&gt;&gt; df.median()
  Age                            28.0
  Work Experience (Yrs)           4.0
  Management Experience (Yrs)     0.0
  dtype: float64
  &gt;&gt;&gt; df.std()
  Age                            5.557843
  Work Experience (Yrs)          4.580132
  Management Experience (Yrs)    2.533848
  dtype: float64
  </code></pre>
  
  <p>Any suggestions on how to do that in Python? Is there a sampling method that does this?
  Thanks</p>