title: Split dataframe into 6 dataframes based on values in another dataframe
body: <p>I am trying to split rows of a dataframe into 6 lists based on values in another dataframe. Working in python with the pandas package. trainX = a dataframe shaped (7352, 561) and trainY = a dataframe shaped (7351, 1)</p>
  <p>What I want is that each row of trainX is sorted into 6 new dataframes, according to the value at the corresponding row in trainY.</p>
  <p>If row 1 in trainY says &quot;1&quot;, then row 1 in trainX should go to dataframe class1. If row 2 in trainY says &quot;2&quot;, then row 2 in trainX should go to dataframe class2. And so forth until all 7351 rows in trainX are divided over classes 1 to 6.</p>
  <p>I tried various things with for loops and iterrows() but I get stuck in syntax. How to solve?</p>