U can use train_test_split from sk-learn or u can code it ur self
If u r coding it ur self all u need to do is get the length of ur training data and multiply it by 0.2, after that use np.random.shuffle( ) to shuffle the data and the perform a slice of the shuffled data like this: test_data = data[-splice:]
where splice = int(len(data)*0.2)