Reputation: 125
I have data frame like this:
x y z
0 AA BB CC
1 BB NaN CC
2 BB AA NaN
and dictionary:
d = {'AA': 1, 'BB': 2, 'CC': 3}
I want to compare values from each cell with values from dictionary and add another new column with sum of these values for each row. In result I need something like this:
x y z sum
0 AA BB CC 6
1 BB NaN CC 5
2 BB AA NaN 3
I need the most efficient solution, any ideas?
Upvotes: 2
Views: 87