def nominal_to_numeric(array): mapper = {name: i for i, name in enumerate(pd.unique(array))} return np.array([mapper[name] for name in array])