-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add "forward" and "nearest" direction to merge_asof() #14887
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
Comments
this is fine. also prob should add an example / expl in docs about how so should have:
|
I like the idea of a As for the difference between |
closes pandas-dev#14887 Author: Christopher C. Aycock <[email protected]> Closes pandas-dev#15129 from chrisaycock/GH14887 and squashes the following commits: da38483 [Christopher C. Aycock] Description of direction parameters is now a bullet-point list 879c9f0 [Christopher C. Aycock] Tweak prose to include statement on version and parameters ce5caaa [Christopher C. Aycock] Split Cython functions according to direction 50431ad [Christopher C. Aycock] ENH: Added 'direction' parameter to merge_asof() (pandas-dev#14887)
May I ask what happened to this PR? How come it was never merged, even though it was added to 0.20.0 milestone at one point? |
this was merged quite a while ago |
Currently
pd.merge_asof()
looks backwards, meaning that it gets the last row from the right table whose timestamp is less the left table's timestamp. It might be nice to look forwards, meaning get the first row in the right table whose timestamps is greater than the left table's timestamp. And we could have a nearest, meaning get the row from the right table whose timestamp is closest to the left table's timestamp regardless of direction.I propose a new
direction
parameter whose default value is"backward"
, which looks for prior timestamps aspd.merge_asof()
currently does. A value of"forward"
will cause cause the function to look for subsequent timestamps. A value of"nearest"
will look on both directions.Here's a modified example from the docstring:
The text was updated successfully, but these errors were encountered: