i have a dataset where I want to split the data set based on the column values. At every iteration, the training set will include all data except those that belong to 2 values which will be kept for test set.
As an example, we have column x with values a, b, c, d, e and f.
At the moment I am doing a manual selection but since I want to try it for every possible combinations, I am not sure how best to do that.
train = df.loc[~df['x'].isin(['a','b'])]
test = df.loc[df['x'].isin(['a','b'])]
How do I change this code to consider all possible combinations?
I would also like to be able to print these combinations to see the combinations that were used for training and test sets.
 
     
     
    