# impute the mean and add an indicator matrix (new in scikit-learn 0.21) imputer = SimpleImputer(add_indicator=True) imputer.fit_transform(X) # After adding missingness indicator array([[20. , 0. ], [30. , 0. ], [10. , 0. ], [17.5, 1. ], [10. , 0. ]])