Range

Compatibility: A set of 3 columns that are all numerical or all datetime

The Range constraint enforces that for all rows, the value of one of the columns is bounded by the values in the other two columns.

Parameters

(required) low_column_name: The name of the column that contains the lowest value

(required) middle_column_name: The name of the column that must be between the low and the high columns

(required) high_column_name: The name of the column that contains the highest value

strict_boundaries: Whether the boundaries between each of the comparisons are strict

(default) True

The middle column must be strictly greater than the low column and strictly less than the high column.

False

The middle column must be greater than or equal to the low column and less than or equal to the high column.

Example

Define your constraint using the parameters and then add it to a synthesizer.

my_constraint = {
    'constraint_class': 'Range',
    'table_name': 'users', # for multi table synthesizers
    'constraint_parameters': {
        'low_column_name': 'child_age',
        'middle_column_name': 'parent_age',
        'high_column_name': 'grandparent_age',
        'strict': True
    }
}

my_synthesizer.add_constraints(constraints=[
    my_constraint
])

FAQs

What happens to missing values?

This constraint ignores missing values. The constraint considered is valid as long as the numerical values (non-missing values) follow the logic.

Last updated

Copyright (c) 2023, DataCebo, Inc.