-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Add strategy="constant" to SimpleImputer #11208
Copy link
Copy link
Closed
Description
SimpleImputer should accept array-like with object, string and categorical dtypes (e.g. pandas dataframes storing categorical variables) and make it possible to replace the np.nan marker by another constant value passed by the user in the constructor.
In particular this would make the ColumnTransformer example #11197 much simpler as suggested by @TomDLT:
num_pl = make_pipeline(
SimpleImputer(strategy='median'),
StandardScaler(),
)
cat_pl = make_pipeline(
SimpleImputer(strategy='constant', fill_value="missing"),
CategoricalEncoder('onehot-dense'),
)
transformer = ColumnTransformer(
[
('num', num_pl, num_feats),
('cat', cat_pl, cat_feats)
],
remainder='drop'
)Note that this will require to also fix #2888 at the same time.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels