1

I have two dataframes. One looks like this:

df1:
    col1    col2    col3   newcol
0    1      2000     10     NaN
1    3      4000     20     NaN     
2    5      8000     30     NaN
...
100  7      2000     23     NaN

Each combination of values in a row is unique.

And a second df.

df2:
      col1   col2    col3    value
...
5      1     2000     10       7
7      3     6600     52       6
...
500    1     1000     78       2

Now i want to compare the two dataframes and put every entry of the df2 column "value" where col1, col2 and col3 matches the entries of df1 into df1 column "newcol".

I tried using ".map" but i couldnt get multiple conditions to work. Is map a good function to use in this scenario?

Expected Output:

df1:
    col1    col2    col3   newcol
0    1      2000     10      7
1    3      4000     20     NaN     
2    5      8000     30     NaN
...
100  7      2000     23     NaN
haddock
  • 33
  • 5
  • Can you post a sample expected output? – davidbilla Dec 05 '19 at 11:04
  • 1
    How about joining on the columns rather than using a map? You can use map to achieve the same but it would be complicated. Map is used when you want to apply some transformation on a particular series. – pecey Dec 05 '19 at 11:07
  • Can join the columns when only some lines fulfill all criteria? – haddock Dec 05 '19 at 11:11

0 Answers0