I have an unbalanced, panel pandas data frame.
I would like to split this data into a training set and a testing set. Python's train_test_split
method will not work because it does a random split, and so, it will likely places observations from t + 1
into the training set, and observations from t
into the test set.
Which, of course, makes no sense, because the future cannot predict the past.
TimeSeriesSplit
will also not work because this function does not take into consideration the panel dimension of my data set.
Is there an easy way to do a train test split on unbalanced panel data sets? This split should (1) take into consideration the panel dimension of the data set, and (2) place earlier observations in the training set and later observations in the testing set.