else:
categories = [x if x is not None else np.nan for x in pd.unique(X[col].values)]
data = {}
if handle_missing == "value":
data[np.nan] = -2
for i in range(len(categories)):
data[categories[i]] = i + 1
if handle_missing == "return_nan":
data[np.nan] = -2
mapping = pd.Series(data)
mapping_out.append({"col": col, "mapping": mapping, "data_type": X[col].dtype}, )
return X, mapping_out
After Change
index = pd.Series(categories).fillna(nan_identity).unique()
data = pd.Series(index=index, data=range(1, len(index) + 1))
if handle_missing == "value" and ~data.index.isnull().any():
data.loc[nan_identity] = -2
elif handle_missing == "return_nan":