1train=df.sample(frac=0.8,random_state=200) #random state is a seed value
2test=df.drop(train.index)
1from sklearn.model_selection import train_test_split
2
3
4y = df.pop('output')
5X = df
6
7X_train,X_test,y_train,y_test = train_test_split(X.index,y,test_size=0.2)
8X.iloc[X_train] # return dataframe train
9
1from sklearn.model_selection import train_test_split
2
3train, test = train_test_split(df, test_size=0.2)
4
1from sklearn.model_selection import train_test_split
2xTrain, xTest, yTrain, yTest = train_test_split(x, y, test_size = 0.2, random_state = 0)
1df_permutated = df.sample(frac=1)
2
3train_size = 0.8
4train_end = int(len(df_permutated)*train_size)
5
6df_train = df_permutated[:train_end]
7df_test = df_permutated[train_end:]