siuba icon indicating copy to clipboard operation
siuba copied to clipboard

joining using one column on left, but multiple on right

Open machow opened this issue 3 years ago • 0 comments

Right now, a major limitation of joins is that the use a dictionary format behind the scenes. E.g.

{"left_key": "right_key", "left_key2": "right_key2"}

This works fine for 99% of cases, but doesn't work if the left keys have the same name. One way around this would be to support tuples in the dict...

{("left_key", "left_key2"): "right_key"}

{"left_key": ("right_key", "right_key2")}

A nice advantage of this format is that it's easy to see which have multiple key entries and to reverse the dictionary. The downside is that often you want to unpack the dictionary into the form...

[("left_key", "right_key"), ("left_key", "right_key2")]

It might be helpful to create a lightweight MultipleMapping class or something to help w/ keys.

machow avatar Aug 31 '20 13:08 machow