def split_data(data, num=30):
    """
    Splits data into train, valid, test datasets

    Parameters:
    -----------
    data: pandas.DataFrame
        the data to split
    num: int (default: 30)
        the number of observations in valid/test
        
    Return:
    --------
    four pandas.DataFrame
        train, valid, test, train_valid datasets
    """  
    train_valid, test = (
        data.iloc[: - num],
        data.iloc[- num:],
    )

    train, valid = (
        train_valid.iloc[: - num], 
        train_valid.iloc[- num:]
    )

    return train, valid, test, train_valid