Skip to content

Conversation

@behzadnouri
Copy link
Contributor

closes #7331

on master:

>>> left dates states 0 20140101 CA 1 20140102 NY 2 20140103 CA >>> right stateid states 0 1 CA 1 2 NY >>> pd.merge(left, right, how='left', on='states', sort=False) dates states stateid 0 20140101 CA 1 1 20140103 CA 1 2 20140102 NY 2 

DataFrame.join already works fine:

>>> left.join(right.set_index('states'), on='states', how='left') dates states stateid 0 20140101 CA 1 1 20140102 NY 2 2 20140103 CA 1 

on branch:

>>> pd.merge(left, right, how='left', on='states', sort=False) dates states stateid 0 20140101 CA 1 1 20140102 NY 2 2 20140103 CA 1 >>> pd.merge(left, right, how='left', on='states', sort=True) dates states stateid 0 20140101 CA 1 1 20140103 CA 1 2 20140102 NY 2 
@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 1, 2014
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the only case where it needs/should be preserved? (e.g. what about other how's)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in pandas/src/join.pyx only left_outer_join accepts this extra argument sort, which was added in this commit to preserve left frame order.

I think it makes sense, because except for the case of left join preserving order is not well defined or I do not see an immediate use for it.

@jreback jreback added this to the 0.15.2 milestone Dec 1, 2014
jreback added a commit that referenced this pull request Dec 1, 2014
BUG: preserve left frame order in left merge
@jreback jreback merged commit e463818 into pandas-dev:master Dec 1, 2014
@jreback
Copy link
Contributor

jreback commented Dec 1, 2014

ok then!

btw, if you are looking for something to do......

#4088 ( I did this a while back, #6647 but it doesn't quite fix this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode

2 participants