polars
polars copied to clipboard
Add strategy="nearest" and strategy="topk" to join_asof
Problem description
I wish I could use Polars to perform an asof
join with the nearest
and topk
strategies, where:
- A “nearest” search selects the row in the right DataFrame whose ‘on’ key is closest in absolute distance to the left’s key
- A "topk" search selects the rows in the right DataFrame whose ‘on’ keys are top k in absolute distances to the left’s key
With some guidance, I think I can implement this in Rust.
I would like to take on this issue in Rust
@ritchie46, how difficult do you think the implementation of the "nearest" strategy would be?
Reference: https://pandas.pydata.org/docs/reference/api/pandas.merge_asof.html?highlight=merge_asof#pandas.merge_asof
https://github.com/pola-rs/polars/pull/9024 adds support for 'nearest'