-
Notifications
You must be signed in to change notification settings - Fork 50
feat: df.join lsuffix and rsuffix support #1857
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
base: main
Are you sure you want to change the base?
Conversation
if how == "cross": | ||
if on is not None: | ||
raise ValueError("'on' is not supported for cross join.") | ||
result_block = left._block.merge( | ||
right._block, | ||
left_join_ids=[], | ||
right_join_ids=[], | ||
suffixes=("", ""), | ||
suffixes=(lsuffix, rsuffix), | ||
how="cross", | ||
sort=True, | ||
) | ||
return DataFrame(result_block) | ||
|
||
# Join left columns with right index | ||
if on is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This if
block is getting pretty long. Might be time for a helper function.
["string_col", "int64_col", "int64_too"] | ||
].rename(columns={"int64_too": "int64_col"}) | ||
pd_result = pd_df_a.join(pd_df_b, how=how, lsuffix="_l", rsuffix="_r") | ||
print(pd_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove leftover print() statements.
PS. Adding --pdb
to your pytest
command line arguments makes dropping into a debugger to inspect variables really easy. https://docs.pytest.org/en/stable/how-to/failures.html#dropping-to-pdb-on-failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
if how == "cross": | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worth added a test that ValueError
is not raise for this condition with a cross join.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross join actually raise another error, match added.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕