I am trying to update DF1 with values from DF2['city'] , both tables have different size, and all are in pandas df.
DF1:
name years job
miki 21 worker
adam 22 PM
mike 51 director
wiola 33 manager
DF2:
name years city
miki 21 NY
adam 22 CAN
Result:
DF1:
name years job city
miki 21 worker NY
adam 22 PM CAN
mike 51 director
wiola 33 manager
I need to take into account only name
and years
columns, if they are same as in second table , just take city
value.
I have tried to do:
DF1[DF1['name']==DF2['name'],'city']=DF2['city']
but its only for one condition city
, i can do separatelly sam for years
But main problem is that i cant do that for different tables ,
i am receiving error: ValueError: Can only compare identically-labeled Series objects
could anyone help me?