polars icon indicating copy to clipboard operation
polars copied to clipboard

Add strategy="nearest" and strategy="topk" to join_asof

Open giorgiosavastano opened this issue 2 years ago • 1 comments

Problem description

I wish I could use Polars to perform an asof join with the nearest and topk strategies, where:

  1. A “nearest” search selects the row in the right DataFrame whose ‘on’ key is closest in absolute distance to the left’s key
  2. 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.

giorgiosavastano avatar Dec 03 '22 13:12 giorgiosavastano

I would like to take on this issue in Rust

giorgiosavastano avatar Dec 03 '22 13:12 giorgiosavastano

@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

benjaminrwilson avatar May 10 '23 03:05 benjaminrwilson

https://github.com/pola-rs/polars/pull/9024 adds support for 'nearest'

MarcoGorelli avatar May 26 '23 10:05 MarcoGorelli