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)
After Change
else:
categories = X[col].unique()
index = pd.Series(categories).fillna(nan_identity).unique()
data = pd.Series(index=index, data=range(1, len(index) + 1))