title: how can i write from scratch code to do stratified sampling by target variable?
body: <p>all, i am trying to create from scratch (without use of sklearn libs) to create 5 samples (len of df / 5) such that each one has the same proportion of target variable (1's) as the original dataset. e.g. original has 5% cancer patients i would like each of my 5 samples to also have 5% target variable. unsure how to do this,</p>
  <pre><code>df_list=[]
  n= round(len(df)/5)
  for m in range(1,6):
      m = m*n
      print(df[:m])
      df_list.append(df[:m])
  </code></pre>
  <p>this creates each chunk i would like but how can i now do it such that the target variable is of same % as original?</p>