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-attr-code-in
description: Per-row 0/1 — whether a field's value is one of a list of codes; its mean is the share of the whole base.
kind: operator
category: ATTR
operator: ATTR_CODE_IN
type: reference
applies_to: process, compose, predict
examples_tags: [feature-engineering, proportion-analysis, streaming-friendly]

Use when

Adds a 1 / 0 field saying whether each row’s code is one of a listed set, keeping every row in the base.

Questions it answers:

  • What share of all respondents gave a top-two-box answer (codes 4 or 5)?
  • Which orders carry one of the priority status codes, as a field to average by region?

Use something else:

  • FILTER_INCLUDE when you want to keep only the rows with those codes.
  • ATTR_SET_HAS when the field is a multi-select.

Params

NameTypeDefaultDescription
codesarray(required)Non-empty; strings or integers (4 ≡ "4"); a fraction → PROCESSING_CONFIG

Inputs

  • field — categorical_u8/u16/u32 (by LABEL, not id); u4/u8/u16/u32/u64 (by exact value; u64 above 2^53 too)
  • label — derived field name; default ATTR_CODE_IN_<field>. A target slot → PROCESSING_CONFIG

Output

packed_bool per row: 1 if the value is a code, else 0. Null → 0.

Contract

  • Types (field): categorical_*, u16, u32, u4, u64, u8; any other scalar type is PULSE_FIELD_TYPE_UNSUPPORTED.
  • Weight: not read; a weight in force is skipped.
  • Streaming: streamable.

Gotchas

  • The label’s mean (AGG_WEIGHTED_MEAN) is the share of the WHOLE base (top-box %). FILTER_INCLUDE on the codes shrinks the base: every cell reads 100%.
  • Nulls count as “no”. To drop them, put FILTER_NULL (values: ["is_not_null"]) first.
  • Integer field: a code not a whole number in range (u4 0..15, u8 0..255…) → PROCESSING_CONFIG.
  • A categorical code absent from the dictionary matches nothing; predict warns PULSE_ATTR_CODE_NOT_IN_DICTIONARY (error under --strict).
  • field must be a schema field: one derived by an earlier attribute or feature → PROCESSING_CONFIG “unknown field”.
  • Row-local: streams; fuses on crosstabs; merges (shards, parallel decode, chain stages).

See