-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/PERF: merge_asof with multiple "by" keys #55580
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
Conversation
rbv = ensure_object(rbv) | ||
|
||
mapped = [ | ||
_factorize_keys( |
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'm assuming this work alright with ExtensionArrays? Do we have tests for merging on by
that is a extension column?
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.
Yes, this will work with EAs. I've parameterized an existing test to include EA dtypes.
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.
Added an additional test as this seems to fix #43541
pandas/core/reshape/merge.py
Outdated
left_by_values[n], | ||
right_by_values[n], | ||
sort=False, | ||
how="outer", |
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.
Not super familiar with this code but does hard coding "outer"
not have any impact? Wondering if there was a case where two dataframes get joined with very few matches
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.
Good point, we can use how=left here. Updated.
Thanks @lukemanley |
merge_asof
gives incorrect results whenby
consists of multiple categorical columns with equal, but differently ordered, categories #43541doc/source/whatsnew/v2.2.0.rst
file if fixing a bug or adding a new feature.