ENH: Do not require to sort entire DF if by
option used in merge_asof
#49816
Labels
Enhancement
Needs Discussion
Requires discussion from core team before further action
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
As a pandas user I'd like to have following behavior when using
merge_asof
.Right now it requires to sort entire DF, but it looks like there is no need to do that if
by
option used.Let me try to explain with example:
If we have 2 dataframes:
And we want to use
merge_asof
to join themSince left df is not sorted we face error:
ValueError: left keys must be sorted
So we need to sort left df first:
But the sort order in result not so obvious as origin sort where each segment with given
id
was sorted independent.Feature Description
It would be nice if pandas require sort only segment, defined by
by
argument inmerge_asof
function.Alternative Solutions
Haven't seen any alternatives.
Additional Context
No response
The text was updated successfully, but these errors were encountered: