mode

mode, function

def nosort process mode(value: _typ): _typ

Returns the most frequent value in each group. Ties are resolved by the canonical ordering.

Examples

table T = with
  [| as Group, as Value |]
  [| "A", "x" |]
  [| "A", "x" |]
  [| "A", "y" |]
  [| "B", "y" |]
  [| "B", "z" |]

table G[g] = by T.Group
G.Mode = mode(T.Value)

show table "Mode" with
  g as "Group"
  G.Mode as "Mode"

This produces the following table:

Group Mode
A x
B y

Remarks

Empty groups return the default value for the data type.

User Contributed Notes
0 notes + add a note