I have been using ‘join’ in accordance with the example given on
https://juliadata.github.io/DataFrames.jl/stable/man/joins/
julia> join(a, b, on = [(:City, :Location), (:Job, :Work)])
Which seems straightforward enough and seems to work. However,
I keep getting these deprecation warnings which are not fatal but worrying
and may slow down my code:
vector containing such tuples as a value of on
keyword argument is deprecated: use Pair{Symbol,Symbol}
instead.
I tried replacing tuples as suggested
julia> join(a, b, on = [Pair{:City, :Location}, Pair{:Job, :Work}])
but that did not work at all.
I can’t seem to find any documentation on this, nor questions on here.
I would be grateful for any hints.
Thanks for any help.
The syntax you want is
julia> join(a, b, on = [:City => :Location, :Job => :Work])
This syntax is a bit clearer on which variable is left and which is right, maybe, as well as being a bit more consistent with the rest of DataFrames.
You are correct that the documentation and deprecation warning are out of date. The documentation is already “fixed” on master. I say “fixed” because the behavior will change a good deal in upcoming releases. Soon we will have innerjoin
, outerjoin
, etc. and the documentation will show the correct use of Pair
s.
1 Like
Thanks so much for that.
I just wonder, because I always thought of indices used in joins (except left/right) as being symmetric in their treatment, but the ‘=>’ would appear to violate this (for instance, in ‘Dict’ objects, aren’t the mappings meant to be unambiguous?)
For this reason, I find this change (away from tuples) a bit confusing.
Thanks again for your help above and any additional.
[BTW, I am doing :left joins in my application, so it makes sense in that case!]
Fair enough, that’s a good point. However given that even if the operation is symmetric, the positions of the arguments never will be. Personally I like =>
because it’s easy to visualize from the positional arguments.
1 Like
Thank you.
PS. If Tuples are not ‘liked’, why not something like <=> ?
PPS Maybe <= for left joins and => for right ones?