I have two dataframes and am trying to update Name in DF1 based on two conditions Tool and Location-
Dataframes -
first one
DF1
NAME Tool Location
- tool_1 location_1
- tool_15 location_2
- tool_19 location_3
and second one -
DF2
NAME Tool Location
name51 tool_1 location_1
name42 tool_15 location_2
name33 tool_19 location_3
I've tried using a numpy where condition checking for both values however am getting error that states -
ValueError: Can only compare identically-labeled Series objects
I understand the problem is different row numbers in both of my dataframes. I've tried some solutions with resetting indexes without any success.
Here is my attempted query -
DF1['NAME'] = np.where((DF1.Tool == DF2.Tool) & (DF1.Location== DF2.Location), DF2.Name)
What could be a work around for this problem ? I am unable to match both dataframes with the exact length of rows.
Expected result for DF1 would be -
DF1
NAME Tool Location
name51 tool_1 location_1
name42 tool_15 location_2
name33 tool_19 location_3
thank you,