def timeseries_train_test_split(df, test_size=0.2, gap=0, ascending=True):
    """Split DataFrame or matrices into random train and test subsets for timeseries
    
    Parameters
    ----------
    df       : pd.DataFrame, shape (n_samples, n_features)
        Training data, where n_samples is the number of samples and n_features is the number of features.
    test_size: float, optional (default=0.2)
        Should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split.
    gap      : int, default=0
        Represents the absolute number of the dropped samples between training set and test set.
    ascending  : boolean, default=True, optional
        Whether timeseries is ascending.
    
    Returns
    -------
    t : list, length=2
        List each list containing train-test split of inputs.
    """
    assert gap>=0, "`gap` should be great than or equal to 0."
    t = df.index.tolist()
    if not ascending:
        t.reverse()
    train_len = round(len(t)*(1-test_size))-gap
    return [t[0:train_len], t[train_len+gap:]]