I have a dictionary which looks like this: di = {1: "A", 2: "B"}
I would like to apply it to the "col3" column of a dataframe similar to using value in "col1" as key to di
:
col1 col2 col3
0 w a U
1 1 2 V
2 2 NaN W
to get:
col1 col2 col3
0 w a U
1 1 2 A
2 2 NaN B
How can I best do this? All answers I found were to replace columns considering them as keys.