Search code examples
joininner-joinjulia

Join on different columns


I want to join 2 dataframes and I'm using the intructions in the Julia guide: http://dataframesjl.readthedocs.org/en/latest/joins_and_indexing.html?highlight=join

join(a, b, on = :ID, kind = :inner)

Now, how I can join on columns with different names:

  • :ID for a
  • :name_id for b

I tried the following but it doesn't work"

join(a, b, on = [ :ID, :name_id ], kind = :inner)

If not implemented, that would be nice feature


Solution

  • The docs on DataFrames.jl provide this example:

    innerjoin(a, b, on = [:City => :Location, :Job => :Work])
    

    So for your example:

    j = innerjoin(a, b, on = :ID => :name_id)