Joining two dataframes of different size only when colum values are coincident


I would like to know what is the best method to join two DataFrames of different size but making one of the variables coincident. Here is an example:

using DataFrames

df11 = DataFrame(time = 0:5:30, num = 1, value1 = rand(7), value2 = rand(7))

df12 = DataFrame(time = 0:5:30, num = 2, value1 = rand(7), value2 = rand(7))

df1 = vcat(df11,df12)

df2 = DataFrame(time = 10:5:25, num = 1, value3 = rand(4))

I would like to outerjoin or leftjoin df1 and df2 with :time but only when in df1 num = 1


now if I do it I can not join them because there are duplicate variable names. makeunique = true does not help to my objective and if i delete the row num the values are assigned to all values of time that coincide.


The idea would be that highlighted values show also missing

Maybe I misunderstood what you want, but shouldn’t this do the trick?

ret = leftjoin(df1,df2, on =  [:time, :num])

Yes it does thank you!