I have one dataframe as below:
Id1 | Id2 |
---|---|
1 | 4 |
2 | 5 |
3 |
The 2nd dataframe is:
ID | Comment |
---|---|
1 | Pears |
2 | Grapes |
3 | Orange |
4 | Banana |
5 | Apple |
How can I get the output like:
Id1 | Id2 | Review |
---|---|---|
1 | 4 | Banana |
2 | 5 | Apple |
3 | Orange |
So, basically I am trying to do a look up for Id2 (from dataframe 1) and get the comment from 2nd dataframe but if the Id2 (in first dataframe) is null then get the Id1 comment from 2nd dataframe.