Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mix of Symbol and Pair in join #2001

Closed
nilshg opened this issue Nov 5, 2019 · 2 comments · Fixed by #2006
Closed

Allow mix of Symbol and Pair in join #2001

nilshg opened this issue Nov 5, 2019 · 2 comments · Fixed by #2006

Comments

@nilshg
Copy link
Contributor

nilshg commented Nov 5, 2019

Currently we can do:

df1 = DataFrame(a = [1,2], b = ["a","b"], c = rand(2))
df2 = DataFrame(a = [1,2], B = ["a","b"], d = rand(2))

join(df1, df2, on = [:a => :a, :b => :B]) 
join(df1, df2, on = [:a]) 
join(df1, df2, on = [:b => :B], makeunique = true)

but it's not possible to do:

join(df1, df2, on = [:a, :b => :B])

This would be very convenient for cases where one has a large number of columns to match on, with only one or two that don't match and require a Pair.

@bkamins
Copy link
Member

bkamins commented Nov 5, 2019

Makes sense and it should not be that hard to do.
Probably we should have something like internal normalize_on function that rewrites any on argument originally passed to be a Vector{Pair}, so that the later code can safely assume only one form (and this operation should be cheap relative to the other things join does).
Then in normalize_on we could make all the checks that the passed argument is valid.

Would you want to make a PR (if you do not have time I will have a look at this).

The only thing we have to be careful about when implementing it is that on master we allow joining more than two data frames in a single call (in which case we do not allow Pairs).

@bkamins
Copy link
Member

bkamins commented Nov 8, 2019

See #2006 for a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants