import pandas as pd
from sklearn.datasets import load_iris
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
# load the iris dataset
iris = load_iris()
# create a dataframe from the iris dataset
df = pd.DataFrame(iris.data, columns=iris.feature_names)
# define the transformations to apply to each column
transformers = [
('numeric', StandardScaler(), iris.feature_names[:2]),
('categorical', OneHotEncoder(), iris.feature_names[2:])
]
# create a column transformer that applies the transformations to the input data
ct = ColumnTransformer(transformers)
# fit and transform the data
X_transformed = ct.fit_transform(df)
# get the feature names
numeric_feature_names = iris.feature_names[:2]
categorical_feature_names = ct.named_transformers_['categorical'].get_feature_names_out(iris.feature_names[2:])
feature_names = list(numeric_feature_names) + list(categorical_feature_names)
# print the feature names
print(feature_names[0:3])