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

Duplicated keys column after join #23

Closed
juba opened this issue Nov 25, 2020 · 2 comments
Closed

Duplicated keys column after join #23

juba opened this issue Nov 25, 2020 · 2 comments
Labels
question Further information is requested

Comments

@juba
Copy link

juba commented Nov 25, 2020

Hi,

First of all, many thanks for this awesome library that makes working with tabular data much more natural. As an Observable newbie coming from R and dplyr, I really appreciate it.

A small question : when joining two tables, the key column(s) are duplicated in the resulting joined table. For example, if both tables are merged on the same key column, the resulting table will have both a key_1 and a key_2 columns. In other languages or libraries I'm accustomed to the fact that the result only has a key column, as the original one.

Please excuse me if it is the intended behavior or if I am misunderstanding something.

Thanks.

@jheer jheer added the question Further information is requested label Nov 25, 2020
@jheer
Copy link
Member

jheer commented Nov 25, 2020

Thanks! This is the intended behavior. The join verb also supports arbitrary predicate functions for testing if two rows match, and so it is not always apparent if two columns are equivalent. To drop unwanted duplicate columns you can do something like this:

dt.join(table, ['key', 'key'], [aq.all(), aq.not('key')])

This will join on two columns both named 'key', with a result that drops the 'key' column drawn from the second table. As a result no suffix will be added to the column drawn from the first table.

@jheer jheer closed this as completed Nov 25, 2020
@juba
Copy link
Author

juba commented Nov 25, 2020

Thanks for the detailed explanation !

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

No branches or pull requests

2 participants