def fit_index(dataset, list_variables):
    """ Mapping between index and category, for categorical variables

    For each (categorical) variable, create 2 dictionaries:
        - index_to_categorical: from the index to the category
        - categorical_to_index: from the category to the index

    Parameters
    ----------
    dataset: pandas.core.frame.DataFrame
        DataFrame with (partly) categorical variables
    list_variables: list(str)
        List of variable names to index

    Returns
    -------
    index: dict
        For each categorical column, we have the 2 mappings: idx2cat & idx2cat
    """

    index = dict()

    for icol in list_variables:

        if icol not in dataset.columns:
            raise RuntimeError(f'{icol} not found in dataframe')

        idx2cat = {ii: jj for ii, jj in enumerate(dataset.loc[:, icol].unique())}
        cat2idx = {jj: ii for ii, jj in idx2cat.items()}

        index[icol] = {
            'index_to_categorical': idx2cat,
            'categorical_to_index': cat2idx
        }

    return index