Skip to content

Select all integer columns.

Description

Select all integer columns.

Usage

cs__integer()

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
)

# Select all integer columns:
df$select(cs$integer())
#> shape: (2, 2)
#> ┌─────┬─────┐
#> │ bar ┆ zap │
#> │ --- ┆ --- │
#> │ i32 ┆ i32 │
#> ╞═════╪═════╡
#> │ 123 ┆ 0   │
#> │ 456 ┆ 1   │
#> └─────┴─────┘
# Select all columns except for those that are integer:
df$select(!cs$integer())
#> shape: (2, 2)
#> ┌─────┬─────┐
#> │ foo ┆ baz │
#> │ --- ┆ --- │
#> │ str ┆ f64 │
#> ╞═════╪═════╡
#> │ x   ┆ 2.0 │
#> │ y   ┆ 5.5 │
#> └─────┴─────┘