Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-agg-mode-count
description: Modal count — how many rows hold the field's most common value; one float64 per output row.
kind: operator
category: AGG
operator: AGG_MODE_COUNT
type: reference
applies_to: process, compose, predict
examples_tags: [cross-tabulation, cardinality-analysis]

Use when

How many rows share a field’s most common value, over all rows or per group.

Questions it answers:

  • How many respondents gave the most common answer?
  • How many orders used the most popular payment method?

Use something else:

  • GROUP_CATEGORY when you want a count for every value of the field: group by it, then count rows.
  • capability:facet when you want per-value counts for several fields in one call.

Params

Weight-aware ("weight": null opts out): the largest per-value Σw (a float), its value the weighted mode. Invalid weights excluded (PULSE_WEIGHT_INVALID_ROWS).

Inputs

ParamAccepted field types
Fieldany type EXCEPT set_*

Output

Scalar float64 — the modal count, NOT a per-value map. Per group under a grouper; grouped by category on the same field it equals each group’s row count.

Components

Weighted adds floor sum_weights, n_eff (probability), n_weight_invalid.

Universal floor {n, n_null} plus operator-specific:

KeyTypeNotes
distinct_countintNumber of distinct values
mode_valueanyModal value (smallest wins a tie)
mode_countintRow count of the modal value (= scalar; weighted: Σw)
  • Mergeability: Partial — per-value count map merged exactly; ProcessChain admits it
  • Streaming: count maps merged at flush

Gotchas

  • Smart default for categorical_* and packed_bool. Memory grows with distinct values.
  • Crosstab margin = modal count of the margin’s own rows, never a sum of cells (class independent: fuses).
  • set_* → PROCESSING_CONFIG.

See