I have the following scikit learn pipeline used for some data preprocessing.
If there is categorical feature in a dataframe, I would like to extract the features and run through SimpleImputer; if there is no such feature (i.e., dataframe['categoricals'] does not exist), I would like it simply "skip"/passthrough the pipeline and proceed to the next step.
How to achieve this?
Pipeline ([
('extract', extract_feature(dataframe['categoricals]),
('fill', SimpleImputer(strategy='constant', fill_value='dummy')
])