Skip to content

Select all unsigned integer columns

Description

Select all unsigned integer columns

Usage

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