from sklearn.compose import ColumnTransformer 
from sklearn.preprocessing import StandardScaler, OneHotEncoder 
import pandas as pd 

# Create some sample data 
data = {'age': [20, 30, 40], 'income': [50000, 60000, 70000],
 'gender': ['male', 'female', 'male'],
 'education': ['high_school', 'university', 'high_school']} 
df = pd.DataFrame(data) 

# ColumnTransformer for numerical and categorical features 
ct = ColumnTransformer(transformers=[ ('num', StandardScaler(),
['age', 'income']),('cat', OneHotEncoder(), ['gender', 'education'])]) 

# Fit and transform the ColumnTransformer on the sample data 
ct.fit(df) 
transformed = ct.transform(df) 

# Get the feature names output by the ColumnTransformer 
feature_names = ct.get_feature_names_out() 

# Print the feature names and the transformed data 
print(feature_names) 
print(transformed)