Pandas Inner Merge/join Returning All Rows
I'm trying to merge two data frames based on a column present in both, keeping only the intersection of the two sets. The desired result is: foo bar foobar x
Solution 1:
Usually it means that you have duplicates in the column(s) used for joining, resulting in cartesian product.
Demo:
In[35]: fooOut[35]:
xyz0a121b342c563d78In[36]: barOut[36]:
xji0a901b902a903a904b90In[37]: pd.merge(foo, bar)
Out[37]:
xyzji0a12901a12902a12903b34904b3490
Post a Comment for "Pandas Inner Merge/join Returning All Rows"