Skip to content

Return the number of non-null values in the column.

Source code

Description

This function is syntactic sugar for pl$col(…)$count().

Usage

pl$count(...)

Arguments

Characters indicating the column names, passed to pl$col(). See ?pl_col for details.

Details

Calling this function without any arguments returns the number of rows in the context. This way of using the function is deprecated. Please use pl$len() instead.

Value

Expression of data type UInt32

See Also

  • pl$len()
  • \$count()

Examples

library("polars")

df = pl$DataFrame(
  a = c(1, 2, NA),
  b = c(3, NA, NA),
  c = c("foo", "bar", "foo")
)

df$select(pl$count("a"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ u32 │
#> ╞═════╡
#> │ 2   │
#> └─────┘
df$select(pl$count(c("b", "c")))
#> shape: (1, 2)
#> ┌─────┬─────┐
#> │ b   ┆ c   │
#> │ --- ┆ --- │
#> │ u32 ┆ u32 │
#> ╞═════╪═════╡
#> │ 1   ┆ 3   │
#> └─────┴─────┘