Select all nested columns
Description
A nested column is a list, array or struct.
Usage
cs__nested()
Value
A Polars selector
See Also
- cs for the documentation on operators supported by selectors.
-
cs$by_dtype()
: Select all columns matching the given dtype(s). -
cs$list()
: Select all list columns. -
cs$array()
: Select all array columns. -
cs$struct()
: Select all struct columns.
Examples
library("polars")
df <- pl$DataFrame(
foo = data.frame(a = c("xx", "x"), b = c("yy", "y")),
bar = c(123, 456),
baz = c(2, 5.5),
wow = list(c(1, 2), c(3)),
)
# Select all nested columns:
df$select(cs$nested())
#> shape: (2, 2)
#> ┌─────────────┬────────────┐
#> │ foo ┆ wow │
#> │ --- ┆ --- │
#> │ struct[2] ┆ list[f64] │
#> ╞═════════════╪════════════╡
#> │ {"xx","yy"} ┆ [1.0, 2.0] │
#> │ {"x","y"} ┆ [3.0] │
#> └─────────────┴────────────┘
#> shape: (2, 2)
#> ┌───────┬─────┐
#> │ bar ┆ baz │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═══════╪═════╡
#> │ 123.0 ┆ 2.0 │
#> │ 456.0 ┆ 5.5 │
#> └───────┴─────┘