I have a categorical column in Polars with 3 categories 'A'
, 'B'
and 'C'
, inferred from a training dataset.
Now suppose there exists a previously-unseen category 'X'
in my test set. I want to handle it like this:
- Add an
'Unknown'
category to the training column - For any unseen categories in test set (e.g.
'X'
), set them to'Unknown'
.
How to accomplish this?
1