hfs.create_mapping_columns_to_nodes

hfs.create_mapping_columns_to_nodes(data: DataFrame, hierarchy: DiGraph)[source]

Creates a mapping from dataset columns to nodes in the hierarchy graph.

For the estimators the hierarchy and the dataset will both be converted to numpy arrays and the column and node names will be lost. Therefore, a mapping to the corresponding indices is created so that after the transformation the correct nodes in the hierarchy can still be found for each column.

Parameters
datapd.Dataframe

The dataset.

hierarchynx.DiGraph

The corresponding hierarchy.

Returns
mappinglist

A list of ints. The value at index i corresponds to the i’th column of the dataset. The value is the index of the corresponding node in the hierarchy.