When dealing with time-series data, one cannot simply do shuffle and split; because there is some knowledge in the order of items. One simple trick is to simply split data based on the age — older data for training, more recent data for testing. But this is not possible if there are different entities, each with a separate record of history.
Here is python function that I have used to split records on water quality measurements to feed to a CNN model. Data has been accumulated for 18 years in around 700 stations — but not uniformly. Some stations have longer history of data, some shorter. Some stations has been measured only once in a few year, and some stations several times a year.
This functions takes care of all the above, and returns two properly shuffled data-frames, which means that the order of time has not bean lost.
If an additional criteria is required — e.g. enforcing a minimum length for the training data, it can be added to the lambda function at line 33.
If there is no specific entity that requires you to group your data accordingly, just set the grouped parameter to False, and all data would be uniformly shuffled, and then will be split around the sort_key.