def folds_formation(global_data, fold_size):
    """
    Function to separate in T-Folds the data, the functions guarantees not having filtrations
    
    Parameters
    ----------
    global_data : pd.DataFrame
        DataFrame with a global dataset
    
    fold_size : str
        'month': every T-Fold will be of one month of historical data
        'quarter': every T-Fold will be of three months (quarter) of historical data
        'year': every T-Fold will be of twelve months of historical data
        'bi-year': every T-Fold will be of 2 years of historical data
        '80-20': Hold out method, 80% for training and 20% for valing
    
    Returns
    -------
    n_data: dict
        A dictionary with the data separated by Fold, stored by keynames according to Fold size
    
    """

    # For quarterly separation of the data
    if fold_size == 'quarter':
        # List of quarters in the dataset
        quarters = list(set(time.quarter for time in list(global_data.index)))
        # List of years in the dataset
        years = set(time.year for time in list(global_data.index))
        q_data = {}
        # New key for every quarter_year
        for y in sorted(list(years)):
            q_data.update({'q_' + str('0') + str(i) + '_' + str(y) if i <= 9 else str(i) + '_' + str(y):
                               global_data[(global_data.index.year == y) & (global_data.index.quarter == i)]
                           for i in quarters})
        return q_data

    # For semester separation of the data
    elif fold_size == 'semester':
        # List of years in the dataset
        years = set(time.year for time in list(global_data.index))
        s_data = {}
        # New key for every semester_year
        for y in sorted(list(years)):
            s_data.update({'s_' + str('0') + str(1) + '_' + str(y):
                               global_data[(global_data.index.year == y) & ((global_data.index.quarter == 1) |
                                      (global_data.index.quarter == 2))]})

            s_data.update({'s_' + str('0') + str(2) + '_' + str(y):
                               global_data[(global_data.index.year == y) &
                                      ((global_data.index.quarter == 3) | (global_data.index.quarter == 4))]})

        return s_data

    # For yearly separation of the data
    elif fold_size == 'year':
        # List of years in the dataset
        years = set(time.year for time in list(global_data.index))
        y_data = {}
        # New key for every year
        for y in sorted(list(years)):
            y_data.update({'y_' + str(y):
                               global_data[(global_data.index.year == y)]})
                               
        return y_data

    # For yearly separation of the data
    elif fold_size == '80-20':
        # List of years in the dataset
        years = sorted(list(set(time.year for time in list(global_data.index))))
        # dict to store data
        a_8 = int(len(years)*0.80) 
        a_2 = int(len(years)*0.20)
        # data construction
        data_80_20 = {'h_8': global_data[global_data.index.year.isin(years[0:a_8])],
                      'h_2': global_data[global_data.index.year.isin(years[a_8:a_8+a_2])]}
    
        return data_80_20