I have a data frame that looks like this:
df = pd.DataFrame(
{
'x' : range(0,5),
'y' : [1,2,3,np.nan, np.nan]
})
I want to impute the values for y and also apply standardization to the two variables with the following code:
columnPreprocess = ColumnTransformer([
('imputer', SimpleImputer(strategy = 'median'), ['x','y']),
('scaler', StandardScaler(), ['x','y'])])
columnPreprocess.fit_transform(df)
However, it seems like the ColumnTransformer would setup separate columns for each steps, with different transformations in different columns. This is not what I intended.
Is there a way to apply different transformation to the same columns and result in the same number of columns in the outputting array?

