Skip to content

add a doc example of SQL's ON statement #4559

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

Closed
cpcloud opened this issue Aug 14, 2013 · 9 comments
Closed

add a doc example of SQL's ON statement #4559

cpcloud opened this issue Aug 14, 2013 · 9 comments
Labels
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Aug 14, 2013

see this SO question

@jreback
Copy link
Contributor

jreback commented Aug 14, 2013

why wouldn't you just pre filter the frames before the merge?

@cpcloud
Copy link
Member Author

cpcloud commented Aug 14, 2013

hmm that's probably how you should do it...ok maybe then a cookbook/sql -> pandas example in docs?

@jreback
Copy link
Contributor

jreback commented Aug 14, 2013

sure

@guyrt
Copy link
Contributor

guyrt commented Aug 17, 2013

That link is dead. Does anyone have a synopsis?

@cpcloud
Copy link
Member Author

cpcloud commented Aug 19, 2013

IIRC the question was about joining two frames with an arbitrary expression in the on kwarg. The solution is to execute the expression and then perform the merge.

@jreback
Copy link
Contributor

jreback commented Aug 19, 2013

@cpcloud maybe make a separate docs tag for things involveing sql/r doc translations?

@cpcloud
Copy link
Member Author

cpcloud commented Aug 19, 2013

good idea

@cpcloud
Copy link
Member Author

cpcloud commented Aug 19, 2013

closing in favor of #4611

@cpcloud cpcloud closed this as completed Aug 19, 2013
@hayd
Copy link
Contributor

hayd commented Aug 20, 2013

Here's the question in full:

Is it possible to pass a generic lambda condition to the merge method, to do something to the effect of:

frame1.merge(frame2, how='left', cond=lambda row1, row2: row2['minA'] <= row1['colA'] <= row2['maxA'])

effectively emulating a generic sql join:

SELECT A.*, B.* FROM A LEFT JOIN B ON A.colA BETWEEN B.minA AND B.maxA..

The only way I can think of right now is to do a cartesian product and then do a filter, which doesn't seem right..

OP deleted it because it was suggested it was a dupe of another question :(.

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

No branches or pull requests

4 participants