Select all numeric columns.
Description
Select all numeric columns.
Usage
cs__numeric()
Value
A Polars selector
See Also
cs for the documentation on operators supported by Polars selectors.
Examples
library("polars")
df <- pl$DataFrame(
foo = c("x", "y"),
bar = c(123L, 456L),
baz = c(2.0, 5.5),
zap = 0:1,
.schema_overrides = list(bar = pl$Int16, baz = pl$Float32, zap = pl$UInt8),
)
# Select all numeric columns:
df$select(cs$numeric())
#> shape: (2, 3)
#> ┌─────┬─────┬─────┐
#> │ bar ┆ baz ┆ zap │
#> │ --- ┆ --- ┆ --- │
#> │ i16 ┆ f32 ┆ u8 │
#> ╞═════╪═════╪═════╡
#> │ 123 ┆ 2.0 ┆ 0 │
#> │ 456 ┆ 5.5 ┆ 1 │
#> └─────┴─────┴─────┘
#> shape: (2, 1)
#> ┌─────┐
#> │ foo │
#> │ --- │
#> │ str │
#> ╞═════╡
#> │ x │
#> │ y │
#> └─────┘