Split data into training and testing set¶

In [11]:
def timeseries_train_test_split_indexes(ts, test_size):
    """
        Gets the two vectors with indexes for the train test split (first vector is train observations, 
        second vector is test observations).
    """
    
    # get the index after which test set starts
    split_time = int(len(ts)*(1-test_size))
    
    test_index=ts.iloc[split_time:].index[0]
    
    return ts.index<test_index, ts.index>=test_index
In [12]:
train_ix, test_ix = timeseries_train_test_split_indexes(timeseries1, 0.3)