title: Split the dataset in train and test based on the group value?
body: <p>If I have the following dataset: (If I group by the data with '<strong>group_name</strong>', the data will look like:)</p>
  
  <p><a href="https://i.stack.imgur.com/Jj9IE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jj9IE.png" alt="enter image description here"></a></p>
  
  <p>I want to split the dataset into train and test set based on the  <code>**group_name**</code> feature. For example, if I want 80:20 ratio, then the train and test set will look like (i.e. in the group-by function):</p>
  
  <p>Train Set: </p>
  
  <p><a href="https://i.stack.imgur.com/kcHqn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kcHqn.png" alt="enter image description here"></a></p>
  
  <p>Test Set:</p>
  
  <p><a href="https://i.stack.imgur.com/DVbgS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DVbgS.png" alt="enter image description here"></a></p>
  
  <p>Thus, the  80:20 ratio is considered in the above example. Also, the above examples shown are the results of the groupby function applied to the actual dataset.  </p>