polars icon indicating copy to clipboard operation
polars copied to clipboard

In join_asof give option to keep the right on column

Open deanm0000 opened this issue 1 year ago • 0 comments

Problem description

Let's say you have

df1 = pl.DataFrame({
    "a": [1, 2, 3, 4, 5, 6, 7]
})

df2 = pl.DataFrame({
    "a": [1, 3, 5, 7],
    "b": [1, 3, 5, 7]
})

and you want to do a join_asof by column a but you want to keep both as for filtering purposes

Right now, if I'm not mistaken, I think you'd have to do:

df1.join_asof(df2.with_column(pl.col('a').alias('a_right')), on = "a")

it'd be nice if we could do df1.join_asof(df2, on = "a", keep_right=True)

deanm0000 avatar Jan 10 '23 20:01 deanm0000