Skip to content

typeset_relations

Predicates and transformers of the inference relations.

Predicates decide from the facts that :func:~.probe.probe_frame computed for every column in one pass, so inference never scans the data itself. Transformers return the column under a new representation: an expression (parsing strings as numbers, dates or booleans) and the facts that hold for it.

Classes

Functions:

string_is_bool(column, state, k)

Every non-null value is a key of the boolean mapping (any case).

numeric_is_category(column, state, k)

A number column with few distinct values is categorical.

to_category(column, state)

Categories are profiled as strings.

string_is_category(column, state, k)

A string column is categorical when

  • it has between one and vars.cat.cardinality_threshold distinct values,
  • the share of distinct values is below vars.cat.percentage_cat_threshold,
  • and it is not a boolean column.

string_is_datetime(column, state)

Every non-empty value parses as a date and at least one does.

Empty strings are allowed: they become missing values of the date column. Among the values that parse, two kinds are not dates:

  • values without a digit (bare month and weekday names are categories);
  • columns of plain numbers: "2024" or "20240101" are read as numbers, so a year column gets the same type whatever its number of distinct values.

string_is_numeric(column, state, k)

Every value converts to a number, at least one is not missing, and the column has more distinct numbers than vars.num.low_categorical_threshold (fewer makes it categorical).