Is there a way to force a transformer to return a pandas dataframe?
Might be late but for anyone with the same question the answers (as almost everything with Scikit-lear) is the usage of Pipelines
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import FunctionTransformer
from sklearn.pipeline import Pipeline
import pandas as pd

df = pd.DataFrame(dict(
    x=[1, 2, np.nan],
    y=[2, np.nan, 0]
))

imputer = Pipeline([(&quot;imputer&quot;, SimpleImputer()),
                    (&quot;pandarizer&quot;,FunctionTransformer(lambda x: pd.DataFrame(x, columns = [&quot;x&quot;, &quot;y&quot;])))])

imputer.fit_transform(df)