Skip to content

type_rules

Type inference rules shared by the pandas and Spark backends.

Each backend computes the facts about a column in its own way (a pandas Series method, a Spark aggregation); the decisions on those facts live here, so both backends apply the same thresholds. The order in which candidate types are tried comes from the typeset (see BaseTypeSet.relations_from).

Classes

Functions:

is_few_numbers(n_unique, config)

A numeric column with at most vars.num.low_categorical_threshold distinct values is categorical.

is_categorical_cardinality(n_unique, n, config)

A string column is categorical when it has between 1 and vars.cat.cardinality_threshold distinct values, and the share of distinct values among the non-null values is below vars.cat.percentage_cat_threshold.

Args: n_unique: distinct non-null values. n: non-null values.