I have the follow two dataframes, and I need calculate value column in the df2 based on df1
df1
col1 col2 col3 value
Chicago M 26 54
NY M 20 21
...
df2
col1 col2 col3 value
NY M 20 ? (should be 21 based on above dataframe)
I am doing loop like below which is slow
for index, row in df2.iterrows():
df1[(df1['col1'] == row['col1'])
& (df1['col2'] == df1['col2'])
&(df1['col3'] == df1['col3'])]['value'].values[0]
how to do it more efficiently/fast?