polars selector starts-with for expression
Select columns that start with the given substring(s).
Signature
> polars selector starts-with {flags} ...rest
Parameters
...rest: Select columns that start with the given substring(s).
Input/output types:
| input | output |
|---|---|
| any | polars_selector |
Examples
Match columns starting with a 'b'
> {
"foo": [1.0, 2.0],
"bar": [3.0, 4.0],
"baz": [5, 6],
"zap": [7, 8],
} |
polars into-df --as-columns |
polars select (polars selector starts-with b) |
polars sort-by bar baz |
polars collect
╭───┬──────┬─────╮
│ # │ bar │ baz │
├───┼──────┼─────┤
│ 0 │ 3.00 │ 5 │
│ 1 │ 4.00 │ 6 │
╰───┴──────┴─────╯Match columns starting with either the letter 'b' or 'z'
> {
"foo": [1.0, 2.0],
"bar": [3.0, 4.0],
"baz": [5, 6],
"zap": [7, 8],
} |
polars into-df --as-columns |
polars select (polars selector starts-with b z) |
polars sort-by bar baz zap |
polars collect
╭───┬──────┬─────┬─────╮
│ # │ bar │ baz │ zap │
├───┼──────┼─────┼─────┤
│ 0 │ 3.00 │ 5 │ 7 │
│ 1 │ 4.00 │ 6 │ 8 │
╰───┴──────┴─────┴─────╯