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:
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
rename!(b, "name_id", "ID")
j = join(a, b, on = :ID, kind = :inner)
rename!(b, "ID", name_id")
The rename changes b, so here I changed it back. (In the general case if there are renaming conflicts within a dataframe you can pick a unique name for each pair of joined names, rename in each dataframe, join and rename back.)
This method is obviously not elegant. It's what I've found so far.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With