Impute entire DataFrame (all columns) using Scikit-learn (sklearn) without iterating over columns
If you want the mean
or median
you could do something like:
fill_NaN = Imputer(missing_values=np.nan, strategy='mean', axis=1)
imputed_DF = pd.DataFrame(fill_NaN.fit_transform(DF))
imputed_DF.columns = DF.columns
imputed_DF.index = DF.index
If you want to fill them with 0s or something you could always just do:
DF[DF.isnull()] = 0
Unless you specifically need to use the sklearn Imputer
for some reason, it seems to me that a simpler option would be to just do:
df = df.fillna(df.mean())