polars
polars copied to clipboard
In join_asof give option to keep the right on column
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 a
s 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)