question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: Support Left Semi Joins

See original GitHub issue

Is your feature request related to a problem?

I wish I could use the Pandas DataFrame.join function to perform left semi joins: selecting each row from the left DataFrame that has at least one matching row in the right DataFrame.

Describe the solution you’d like

I would like to be able to pass leftsemi to the how parameter in the DataDrame.join function to perform this type of join.

Additional context

For example: in SQL this might look like

SELECT *
FROM table1
WHERE EXISTS
(SELECT 1
FROM   table2
WHERE  table1.id = table2.id)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
debnathshohamcommented, Aug 21, 2021

Merge can happen using on, left_on & right_on, right_index & left_index, left_index & right_on and right_index & left_on. If none of these are provided, it tries on the common columns.

Yes, actually you have just considered 2 cases from the 5 I mentioned (you will get a clear picture, if you play around with all these existing merging procedures).

The idea is really simple, in leftsemi, check for the keys in left (can be either index(s) or column(s)) isin the keys in the right (again, could be either index(s) or column(s)). And return those keys from left.

You can check this example from stack. Hope this will clarify.

1reaction
debnathshohamcommented, Aug 21, 2021

Great! To answer the questions above:

  1. Correct
  2. Merge can happen using on, left_on & right_on, right_index & left_index, left_index & right_on and right_index & left_on. If none of these are provided, it tries on the common columns.
  3. AFAIU semi join should only returns rows from left that has matching rows in right. It won’t add columns from right.

Hope that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does SQL Server support join type "LEFT SEMI JOIN" in your ...
I never know SQL Server supports the LEFT SEMI JOIN syntax, so I give it a try with the following code. USE tempdb;...
Read more >
Null-Accepting Semi-Join | Mohamed Houri's Oracle Notes
It extends the semi-join algorithm to qualify rows from the table in the left hand side that have a null value in the...
Read more >
Work around BigQuery LEFT [ OUTER | SEMI | ANTI ] JOIN ...
LEFT JOIN would require a CROSS JOIN and then filtering · SEMI JOIN and ANTI JOIN can use COUNTIF() filters.
Read more >
What is the difference between INNER JOIN and LEFT SEMI ...
Both INNER JOIN and LEFT SEMI JOIN return matching records between both tables with a subtle difference. Let's consider 2 tables – employee ......
Read more >
Part#8. CDS Views – Joins and Associations - SAP Blogs
Inner Join; Left Outer join; Right outer join ... To overcome this problem, SAP did an enhancement to this SQL way of getting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found