I have two dataframes. One dataframe one first, dataframe two second.
I want to replace country value based on DF 2.
| Code | Country | Column C | Column D |
|---|---|---|---|
| 100 | NULL | foo | mei |
| 200 | NULL | bar | tes |
| 100 | NULL | foo1 | mei1 |
| 200 | NULL | bar1 | tes1 |
| 100 | NULL | foo2 | mei2 |
| 200 | NULL | bar2 | tes2 |
| Code | Country |
|---|---|
| 100 | Canada |
| 200 | USA |
Tried:
df1['Country'] = df2.replace(df1['Code'],df1['Country']
But this is throwing error: Columns must be same length as key
| Code | Country | Column C | Column D |
|---|---|---|---|
| 100 | Canada | foo | mei |
| 200 | USA | bar | tes |
| 100 | Canada | foo1 | mei1 |
| 200 | USA | bar1 | tes1 |
| 100 | Canada | foo2 | mei2 |
| 200 | USA | bar2 | tes2 |