This can be achieved by using the scikit machine learning  library and importing train_test_split function in python as shown below:
Import sklearn.model_selection.train_test_split
# test size =30% and train= 70 %
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=0).