I have two dataframes loaded up from csv files in Python.
One of it contains the following type of data:
Well Zones Inflow
E18 A 0.45
E23 B 0.33
E25 C 0.2
E18 B 0.2
E23 A 0.67
E25 D 0.12
E23 B 0.2
E18 A 0.67
E25 D 0.12
and the other:
Well Zones Distance
E18 A 5.3
E23 B 2.1
E25 C 4.8
E18 B 5.4
E23 A 2.3
E25 D 5.5
What I need to do is to match two dataframes, based on two conditions, "Well" and "Zones", to get the first dataframe updated as following:
Well Zones Inflow Distance
E18 A 0.45 5.3
E23 B 0.33 2.1
E25 C 0.2 4.8
E18 B 0.2 5.4
E23 A 0.67 2.3
E25 D 0.12 5.5
It may seem trivial from above example, because I have included it here only for the description of my problem. The actual data is a really big file with the data in original file shuffled.
This is what I have used to match based only on one criterion and it works perfectly:
df1.insert(13, 'Distance', df1['Well'].map(df2.set_index('Well')['Distance']))
***13 is the column to insert the matched data from
However, what I need is the same (or any other) way to match two dataframes, but with 2 or more conditions (because depending on zone and well the distance differs), so, not only "Well" but "Well" + "Zones" conditions.