def numerical_to_categorical(df, categorical_fields, transitional_dfs):
    """
    Converts numerical data back to categorical
    :param df: original data-frame with numerical data
    :param categorical_fields: list of strings (attribute names that have to be converted from numerical
    to categorical)
    :param transitional_dfs: dictionary returned by categorical_to_numerical function
    :return: new data-frame where requested numerical fields have been turned to categorical
    """
    df_final = df.copy()

    for categorical_field in categorical_fields:
        for index, row in df.iterrows():
            discrete_value = 0

            # searching for the corresponding interval
            for index2, row2 in transitional_dfs[categorical_field + "_NUM"].iterrows():
                if row2["interval_down"] <= df[categorical_field + "_NUM"][index] <= row2["interval_up"]:
                    discrete_value = row2["unique_values"]
            df_final.loc[index, categorical_field] = discrete_value
        del df_final[categorical_field + "_NUM"]
    return df_final