I have two data frames
df1: 4 columns and 2000 rows
E G H L
0
1
2
3
...
df2: 26 columns (can be more later) and unknown rows
A B C D E ... Z
0
1
2
3
...
I want to update column L of df2 with the value of column L of df1 in such a way that if the value of columns E G H is the same in df1 and df2.
I tried different solutions I found in Stackoverflow but I got different errors.
For example from based on this Q/A: Compare two pandas dataframes and update one, depending on results
I tried :
if df2['E'] == df1['E'] and df2['G'] == df1['G'] and \
df2['H'] == df1['h']:
df2['L'] = df1['L']
I got ValueError: Can only compare identically-labeled Series objects
based on Pandas "Can only compare identically-labeled DataFrame objects" error I change it to
if df2['E'] == df1['E'] and df2['G'] == df1['G'] and \
df2['H'] == df1['h'] and df1.reset_index(drop=True) == df2.reset_index(drop=True):
df2['L'] = df1['L']
and I got the same error
Here is more information: df1 is actually a map and based on the value of the columns E G H I have to find the value of L and put it in the same rows in the column L of df2. Here is an example: Assuming that in data frame 1 I have
E item: RAM, G stock: No-2, H State(Province):NY, L Part Code:5X456
Now for every row in the data frame 2 that the value of E item, G stock, and H State is the same as above I need to update L Part Code to 5X456.