Complex column selection beyond simple name lists:
Available selectors:
.numeric(): Numeric columns (int or float).integer(): Integer columns only.float(): Floating-point columns.string(): String columns.categorical(): Categorical columns.any_date(): Date or datetime columns.boolean(): Boolean columns.all(): All columns.has_nulls(): Columns with at least one null.cardinality_below(threshold): Few unique values.cols("name"): Specific column name(s).glob("pattern*"): Unix shell-style globbing.regex("pattern"): Regular expressionsUse logical operators:
# Inverse: NOT numeric
~s.numeric()
# OR: datetime columns OR string columns
s.any_date() | s.string()
# AND: string columns without nulls
s.string() & ~s.has_nulls()
# XOR: either string, or name starts with "date_" but not both
s.string() ^ s.glob("date_*")
# Include: string columns and col "date"
s.string() | "date"
# Exclude: all columns except "datetime-col"
s.all() - "datetime-col"Get the list of selected columns:
| name | |
|---|---|
| 0 | ALICE |
| 1 | None |
| 2 | CHARLIE |
expand() extracts selected column namesApplyToCols, SelectCols, DropCols