digits = self.calc_required_digits(X, col)
X_unique = pd.DataFrame(index=values)
X_unique_to_cols = X_unique.index.map(lambda x: self.col_transform(x, digits))
for dig in range(digits):
X_unique[str(col) + "_%d" % (dig,)] = X_unique_to_cols.map(
lambda r: int(r[dig]) if r is not None else None)
After Change
digits = self.calc_required_digits(values)
X_unique = pd.DataFrame(index=values,
columns=[str(col) + "_%d" % x for x in range(digits)],
data=np.array([self.col_transform(x, digits) for x in range(1, len(values) + 1)]))
if self.handle_unknown == "return_nan":
X_unique.loc[-1] = np.nan