Skip to main content
Version: 0.9.6

Expr.count

def count() -> Expr

Categories: aggregation

Aggregation operation that counts the non null values of the given column in the group.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a ┆ b │
------
str ┆ i64 │
╞══════╪══════╡
│ A ┆ 1
│ B ┆ 2
│ A ┆ 3
│ B ┆ 0
│ C ┆ 5
│ null ┆ 6
│ C ┆ null │
└──────┴──────┘
>>>
>>> tf.group_by(td.col("a")).agg(td.col("b")).count().alias("count"))
>>>
┌──────┬───────┐
│ a ┆ count │
------
str ┆ u32 │
╞══════╪═══════╡
│ null ┆ 1
│ A ┆ 2
│ B ┆ 2
│ C ┆ 1
└──────┴───────┘