-
Notifications
You must be signed in to change notification settings - Fork 170
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Related
- Support set operations on selectors #224
- feat: implement selectors set arithmetic #247
- https://github.com/pola-rs/polars/blob/b9dd8cdbd6e6ec8373110536955ed5940b9460ec/crates/polars-plan/src/dsl/selector.rs#L10-L16
- https://docs.pola.rs/api/python/stable/reference/selectors.html#set-operations
- https://en.wikipedia.org/wiki/Symmetric_difference
Description
I can't seem to find this ever being discussed - but while working on modeling selectors in (#2572) it looks like we're missing 1 set operator (^).
Example from the polars docs:
import polars.selectors as cs
import polars as pl
# set up an empty dataframe with plenty of columns of various dtypes
df = pl.DataFrame(
schema={
"abc": pl.UInt16,
"bbb": pl.UInt32,
"cde": pl.Float64,
"def": pl.Float32,
"eee": pl.Boolean,
"fgg": pl.Boolean,
"ghi": pl.Time,
"JJK": pl.Date,
"Lmn": pl.Duration,
"opp": pl.Datetime("ms"),
"qqR": pl.String,
},
)
# Select the SYMMETRIC DIFFERENCE of numeric columns and columns that contain an "e"
assert df.select(cs.contains("e") ^ cs.numeric()).schema == {
"abc": UInt16,
"bbb": UInt32,
"eee": Boolean,
}Considering that we do support the other 4 (&, |, -, ~) operators, it would round out the set nicely 😉
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request