I have following dataframe named df.
| id | letter |
|---|---|
| 1 | x,y |
| 2 | z |
| 3 | a |
The mapping condition is {'x' : 1, 'z' : 2, 'ELSE' : 0}
my desired output dataframe should look like,
| id | letter | map |
|---|---|---|
| 1 | x,y | 1 |
| 2 | z | 2 |
| 2 | a | 0 |
Which means, even any of the letters in column letter is x, then the column map should be 1.
Without iterating through each row of the dataframe, is there any way to do that?
'x,z'?