Skip to content

Count elements

Source code

Description

Count the number of elements in this expression. Note that NULL values are also counted. $len() is an alias.

Usage

<Expr>$count()

Expr_len()

Value

Expr

Examples

library(polars)

pl$DataFrame(
  all = c(TRUE, TRUE),
  any = c(TRUE, FALSE),
  none = c(FALSE, FALSE)
)$select(
  pl$all()$count()
)
#> shape: (1, 3)
#> ┌─────┬─────┬──────┐
#> │ all ┆ any ┆ none │
#> │ --- ┆ --- ┆ ---  │
#> │ u32 ┆ u32 ┆ u32  │
#> ╞═════╪═════╪══════╡
#> │ 2   ┆ 2   ┆ 2    │
#> └─────┴─────┴──────┘