Here is what I’m doing now, which is filtering out the rows I don’t want after a cross join. I’m joining on two identical columns, and only care about combinations not permutations. Is there a way to do this without generating the rows I don’t want in the first place?
import polars as pl
df1 = pl.DataFrame({"a":np.arange(3)})
df2 = pl.DataFrame({"b":np.arange(3)})
want = df1.join(df2, how="cross").filter(pl.col("a")<pl.col("b"))
print(want)
shape: (3, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i32 ┆ i32 │
╞═════╪═════╡
│ 0 ┆ 1 │
│ 0 ┆ 2 │
│ 1 ┆ 2 │
└─────┴─────┘