# How to replace categorical variables in the testset with their WOE calculated using a training set?

I have calculated the Weight of evidence of two high cardinality variables(Postal_Code_L and Managing_Sales_Office_Nbr) using the instances in a training set in Python.

The problem is that now I want to replace the values of these high cardinality variables in instances of the test set with their WOE. How can I do this?

First 20 instances of the high cardinality variables and their WOE. For instances in the test set, the WOE is missing and should be replaced with the WOE calculated using the instances of the training set: