Код: Выделить всё
# categorical columns to encode: Cols_to_encod
Cols_to_encod = list(X.columns[X.dtypes == 'object'])
# create the transformers
ohe = OneHotEncoder(sparse=False, handle_unknown='ignore')
ct = ColumnTransformer(transformers=[('onehot', ohe, Cols_to_encod)], remainder='passthrough')
X_transformed = ct.fit_transform(X)
# get the transformed column names
ohe_names = ct.get_feature_names_out(Cols_to_encod)
Подробнее здесь: https://stackoverflow.com/questions/759 ... e-names-in