itacart.serialization.data_tree_blob.DataVariable

class itacart.serialization.data_tree_blob.DataVariable(name, dtype, species='pyramid', op='none', absent='unknown', weight=None, leaf_max=None)[source]

Bases: NamedTuple

One column of a DataTreeBlob.

Parameters:
  • name (str) – Unique name, 1 to 255 bytes of UTF-8. It lives in the schema; no text is stored per cell.

  • dtype (str) – One of u8, u16, u32, u64, i8, i16, i32, i64, f32, f64. A categorical variable is an integer code.

  • species (str, default: 'pyramid') – "pyramid", observed at the leaves and aggregated at every internal node, or "level", observed at any node and never aggregated.

  • op (str, default: 'none') – For a pyramid variable, "sum", "mean", "max", "min", "mode" (ties go to the smallest value) or "none", which leaves internal nodes without a value. A level variable takes "none".

  • absent (str, default: 'unknown') – What a missing value means: "unknown" or "zero".

  • weight (str | None, default: None) – Required for "mean" and "mode", refused otherwise: the name of an integer pyramid sum declared earlier, whose value at each daughter weights it. Normally the count of the cells where the averaged value was observed.

  • leaf_max (int | None, default: None) – Optional, for an unsigned pyramid sum: the largest value one observation cell holds. With it, each level is written in the narrowest unsigned type its structure can fill.

Example

>>> DataVariable("height", "u16", op="max").op
'max'
name: str

Alias for field number 0

dtype: str

Alias for field number 1

species: str

Alias for field number 2

op: str

Alias for field number 3

absent: str

Alias for field number 4

weight: str | None

Alias for field number 5

leaf_max: int | None

Alias for field number 6

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.