How is the fit function in SimpleImputer working to find the mean in the Salary column as well when just the Age column is given as its argument?
imputer = imputer.fit(df[['Age']])    
X[:, 1:3] = imputer.fit_transform(X[:, 1:3])

You are again applying &quot;fit&quot; with fit_trasnform. Try with &quot;transform&quot; only
You will get a value error

ValueError: X has 3 features per sample, expected 2