Skip to content

Perform an aggregation of bitwise ANDs.

Description

Perform an aggregation of bitwise ANDs.

Usage

<Expr>$bitwise_and()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(n = -1:1)
df$select(pl$col("n")$bitwise_and())
#> shape: (1, 1)
#> ┌─────┐
#> │ n   │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 0   │
#> └─────┘
df <- pl$DataFrame(
  grouper = c("a", "a", "a", "b", "b"),
  n = c(-1L, 0L, 1L, -1L, 1L)
)
df$group_by("grouper", .maintain_order = TRUE)$agg(pl$col("n")$bitwise_and())
#> shape: (2, 2)
#> ┌─────────┬─────┐
#> │ grouper ┆ n   │
#> │ ---     ┆ --- │
#> │ str     ┆ i32 │
#> ╞═════════╪═════╡
#> │ a       ┆ 0   │
#> │ b       ┆ 1   │
#> └─────────┴─────┘