How do I create test and train samples from one dataframe with pandas?
I would just use numpy's
In : df = pd.DataFrame(np.random.randn(100, 2))In : msk = np.random.rand(len(df)) < 0.8In : train = df[msk]In : test = df[~msk]
And just to see this has worked:
In : len(test)Out: 21In : len(train)Out: 79