You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I would find it very helpful to be able to merge dataframes without common columns, (which is allowed in R), e.g.
x = DataFrame({'farm' : ['A','B','C']})
y = DataFrame({'crop':['wheat','millet']})
so that x.merge(y, how='outer') returns:
farm crop
0 A wheat
1 A millet
2 B wheat
3 B millet
4 C wheat
5 C millet
Currently pandas returns: MergeError: No common columns to perform merge on.
One work-around is to set the indices of x and y to zero, perform a join and the reset the index, as per this StackOverflow post. Another use case is here.
Alternatively, if there is a better solution, please let me know. Thanks!
The text was updated successfully, but these errors were encountered:
Thanks, I didn't see that one. Yes, although my suggested solution is a little different, ie. generalizing how merge works with how='outer', rather than adding a new how='cross'.
going to close this as a dupe (but its linked); I think its better add a different how='cross' to avoid accidental merges when their are no overlapping columns (and it wasn't explicitly specified). but that's in the future when this is implemented.
of course if you are interested in doing a PR, would be great!
this isn't that difficult as I think the proposed soln is actually fine;
Hi,
I would find it very helpful to be able to merge dataframes without common columns, (which is allowed in R), e.g.
so that
x.merge(y, how='outer')
returns:Currently pandas returns:
MergeError: No common columns to perform merge on
.One work-around is to set the indices of
x
andy
to zero, perform ajoin
and the reset the index, as per this StackOverflow post. Another use case is here.Alternatively, if there is a better solution, please let me know. Thanks!
The text was updated successfully, but these errors were encountered: