annie.dataset.manipulate¶
Browse ‘Manipulate’ transforms — derive a display/filter value per label column.
A label column carries raw CSV text plus a data type (str / int /
float, chosen when the CSV is added). The Browse Manipulate block then applies
one transform per column, replacing its raw value for tags and filtering:
text →
trim(strip surrounding whitespace);numeric →
round(to the nearest integer, e.g. sentiment1.0→1),threshold(≥X/<Xbuckets), orsign(negative/zero/positive).
The functions are pure and unit-tested; the UI only wires them up.
Attributes¶
A column's data type. |
|
A transform a column can carry. |
|
Short human labels for the transform dropdown. |
Classes¶
One column's transform. |
Functions¶
|
Return the transforms valid for a column type. |
|
Guess a column's type from a sample of its (string) values. |
|
Apply a column's transform to one raw value, returning its display value. |
Module Contents¶
- annie.dataset.manipulate.ColumnType¶
A column’s data type.
- annie.dataset.manipulate.TransformKind¶
A transform a column can carry.
- annie.dataset.manipulate.TRANSFORM_LABELS: dict[TransformKind, str]¶
Short human labels for the transform dropdown.
- class annie.dataset.manipulate.Transform[source]¶
One column’s transform.
- kind¶
The transform to apply.
- threshold¶
The cut for the
thresholdtransform.
- digits¶
Decimal places for the
roundtransform (default 2).
- show_original¶
Display the untransformed value on the sample rows while the filter still matches on the transformed one. This separates the two jobs a transform does:
threshold ≥ 0on a[-3, 3]sentiment makes a clean two-way filter facet, but the reviewer usually still wants to read the real1.83on the row. Purely a display flag — filtering never consults it.
- annie.dataset.manipulate.transforms_for(col_type: ColumnType) tuple[TransformKind, ...][source]¶
Return the transforms valid for a column type.
- annie.dataset.manipulate.detect_type(values: collections.abc.Iterable[str]) ColumnType[source]¶
Guess a column’s type from a sample of its (string) values.
- Parameters:
values – Sample cell values.
- Returns:
"int"if every non-empty value is an integer,"float"if every value is numeric, else"str". An all-empty/absent column defaults to"str".
- annie.dataset.manipulate.apply_transform(value: str, col_type: ColumnType, transform: Transform) str[source]¶
Apply a column’s transform to one raw value, returning its display value.
A value that cannot be parsed as a number (in a numeric column) is returned unchanged, so a stray non-numeric cell never breaks the row.
- Parameters:
value – The raw cell text.
col_type – The column’s data type.
transform – The transform to apply.
- Returns:
The transformed string.