0

I am trying to join two tables based on two columns. Let's say we have:

df1 = key    atTime    c   d   e
      1      3         4   a   100
      23     8         3   g   230
      ...
df2 = xkey    xatTime   z
      30      2         p
      1       3         l
      ...

Now I want to merge/join these two dataframes in a way that only if they have the same keys and the same at time that row gets merged. In this example I want to achieve something like(left join is done here):

resultDF = key    atTime    c   d   e   z
           1      3         4   a   100  l
           23     8         3   g   230  nan

How can I achieve a merge in pandas that goes based off of two columns?

Thanks

Amin
  • 99
  • 5

0 Answers0