You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CategoricalImputer fails when fill_value is already a category #1113
This raises ValueError: new categories must not include old categories: {'unknown'}. I expected ['east', 'unknown', 'west'], with the categorical dtype preserved. It also fails with an ordered categorical; the equivalent object column works.
Reproduced on current main (d866312), Python 3.12, pandas 2.3.3 and scikit-learn 1.7.2. This is related to #1095, but #1096 changes RareLabelEncoder, not this imputer's separate add_categories call.
I'm happy to contribute the fix and regression tests, and I'm planning to work on this.
Activity
solegalli commentedon Nov 18, 2026
Hi @AryanRG
Happy for you to work on this issue. If you do, please add a comment here and also make the PR to the narwhals-migration branch: https://github.com/feature-engine/feature_engine/tree/narwhals-migration which contains the latest version of the code.
Thank you!
AryanRG commentedon Nov 18, 2026
Thanks @solegalli, I’ll take this and target
narwhals-migration.