I have 2 DataFrames, where a column of df1 must be compared to another column, in df2, that have different dimensions, and if true, modify de df1[3].
if df1.loc[df1[1]] == df2.loc[df2[3]]:
df1[3] = 4
df1:
| 0 | 1 | 2 | 3 |
|---|---|---|---|
| yy | 123 | x | |
| xx | 445 | r | |
| za | 336 | f | |
| gs | 775 | e | |
| fr | 447 | w |
df2:
| 0 | 1 | 2 | 3 |
|---|---|---|---|
| T | 0 | x | 336 |
| S | 4 | r | 447 |
| R | 3 | f | 445 |
Expected result should be:
df1:
| 0 | 1 | 2 | 3 |
|---|---|---|---|
| yy | 123 | x | |
| xx | 445 | r | 4 |
| za | 336 | f | 4 |
| gs | 775 | e | |
| fr | 447 | w | 4 |
KeyError:None of [Index ... type='object', length=...)] are in the [index]"
Can someone help me with this? I know that probably is a simple thing, but i've tried a lot of ways and none of works.