data = [['a', 1, 2], ['b', 1, 1], ['b', 2, 2], [np.nan, np.nan, np.nan]]
X = pd.DataFrame(data)
xt = DataFrameImputer().fit_transform(X)
print('before...')
print(X)
print('after...')
print(xt)
Impute categorical missing values in scikit-learn