I have the following df
ID Code
ABCD 00FQ
JKFA 8LK9|4F5H
QWST 2RLA|R1T5&8LK9
I am trying to map a dictionary (where the values are List) to the individual elements of Code.
The dictionary looks like so:
d={'00FQ':"['A','B']", '8LK9':"['X']", '4F5H':"['U','Z']", '2RLA':"['H','K']", 'R1T5':"['B','G']" }
I want to map this dict to each element in the Code column separated by |.
The resulting df would look like so:
ID Code Logic
ABCD 00FQ ['A','B']
JKFA 8LK9|4F5H ['X'] | ['U','Z']
QWST 2RLA|R1T5&8LK9 ['H','K'] | ['B','G'] & ['X']
from Mapping dictionary to partial string match in dataframe
No comments:
Post a Comment