Skip to content

Select all signed integer columns

Description

Select all signed integer columns

Usage

cs__signed_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(-123L, -456L),
  bar = c(3456L, 6789L),
  baz = c(7654L, 4321L),
  zap = c("ab", "cd"),
  .schema_overrides = list(bar = pl$UInt32, baz = pl$UInt64),
)

# Select signed integer columns:
df$select(cs$signed_integer())
#> shape: (2, 1)
#> ┌──────┐
#> │ foo  │
#> │ ---  │
#> │ i32  │
#> ╞══════╡
#> │ -123 │
#> │ -456 │
#> └──────┘
# Select all columns except for those that are signed integer:
df$select(!cs$signed_integer())
#> shape: (2, 3)
#> ┌──────┬──────┬─────┐
#> │ bar  ┆ baz  ┆ zap │
#> │ ---  ┆ ---  ┆ --- │
#> │ u32  ┆ u64  ┆ str │
#> ╞══════╪══════╪═════╡
#> │ 3456 ┆ 7654 ┆ ab  │
#> │ 6789 ┆ 4321 ┆ cd  │
#> └──────┴──────┴─────┘
# Select all integer columns (both signed and unsigned):
df$select(cs$integer())
#> shape: (2, 3)
#> ┌──────┬──────┬──────┐
#> │ foo  ┆ bar  ┆ baz  │
#> │ ---  ┆ ---  ┆ ---  │
#> │ i32  ┆ u32  ┆ u64  │
#> ╞══════╪══════╪══════╡
#> │ -123 ┆ 3456 ┆ 7654 │
#> │ -456 ┆ 6789 ┆ 4321 │
#> └──────┴──────┴──────┘