Constraints
The ydata-sdk provides a Constraint Engine to define and enforce data quality rules against any Dataset. Constraints can check individual row values (e.g. no nulls, valid ranges) or aggregate column statistics (e.g. mean within bounds, null rate below a threshold).
from ydata.constraints import ConstraintEngine, NotNull, Unique, MeanBetween
engine = ConstraintEngine([
NotNull(columns=["age", "income"]),
Unique(columns=["customer_id"]),
MeanBetween(lower_bound=20, upper_bound=60, columns=["age"]),
])
engine.validate(dataset)
print(engine.summary())
# Remove rows that violate any row constraint
clean = engine.filter(dataset)
For a full reference of all available constraints, the CustomConstraint factory, and advanced engine usage, see the Constraints section.