Method: Polars::Expr#unique_counts

Defined in:
lib/polars/expr.rb

#unique_countsExpr

Return a count of the unique values in the order of appearance.

This method differs from value_counts in that it does not return the values, only the counts and might be faster

Examples:

df = Polars::DataFrame.new(
  {
    "id" => ["a", "b", "b", "c", "c", "c"]
  }
)
df.select(
  [
    Polars.col("id").unique_counts
  ]
)
# =>
# shape: (3, 1)
# ┌─────┐
# │ id  │
# │ --- │
# │ u32 │
# ╞═════╡
# │ 1   │
# │ 2   │
# │ 3   │
# └─────┘

Returns:

[View source]

6711
6712
6713
# File 'lib/polars/expr.rb', line 6711

def unique_counts
  _from_rbexpr(_rbexpr.unique_counts)
end