Column Constraints API
MeanBetween
ydata.constraints.columns.constraint.MeanBetween
Bases: Interval
Check that the mean of each column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bound
|
int | float
|
Lower bound (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Example
MeanBetween(lower_bound=30, upper_bound=40, columns="age")
StandardDeviationBetween
ydata.constraints.columns.constraint.StandardDeviationBetween
Bases: Interval
Check that the standard deviation of each column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bound
|
int | float
|
Lower bound (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
QuantileBetween
ydata.constraints.columns.constraint.QuantileBetween
Bases: Interval
Check that a quantile of each column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantile
|
float
|
Quantile to compute, between 0 and 1 (e.g. |
required |
lower_bound
|
int | float
|
Lower bound (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Example
QuantileBetween(quantile=0.95, lower_bound=0, upper_bound=5000, columns="amount")
MinBetween
ydata.constraints.columns.constraint.MinBetween
Bases: Interval
Check that the minimum value of a column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bound
|
int | float
|
Lower bound on the column minimum (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound on the column minimum (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
MaxBetween
ydata.constraints.columns.constraint.MaxBetween
Bases: Interval
Check that the maximum value of a column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bound
|
int | float
|
Lower bound on the column maximum (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound on the column maximum (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
NullRateLowerThan
ydata.constraints.columns.constraint.NullRateLowerThan
Bases: LowerThan
Check that the proportion of null values in a column is at most a threshold.
Unlike :class:NullValuesCountLowerThan, which requires knowing the
absolute count, this constraint uses a rate in [0, 1] and therefore
works regardless of dataset size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Maximum allowed null rate (inclusive), e.g. |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
NullValuesCountLowerThan
ydata.constraints.columns.constraint.NullValuesCountLowerThan
Bases: LowerThan
Check that the number of null (NaN) values in each column is at most value.
Nulls are detected with numpy.isnan, so the columns must be numeric.
For a size-independent check, use :class:NullRateLowerThan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | float
|
Maximum allowed number of nulls (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
UniqueValuesBetween
ydata.constraints.columns.constraint.UniqueValuesBetween
Bases: Interval
Check that the number of distinct values in each column falls inside (lower_bound, upper_bound].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bound
|
int | float
|
Lower bound on the distinct count (exclusive). |
required |
upper_bound
|
int | float
|
Upper bound on the distinct count (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Constant
ydata.constraints.columns.constraint.Constant
SumLowerThan
ydata.constraints.columns.constraint.SumLowerThan
Interval
ydata.constraints.columns.constraint.Interval
Bases: ColumnConstraint
Check that a statistic of each column falls inside an interval.
check computes one scalar from the column (e.g. numpy.mean); the
column passes when that value lies in the interval. Most column
constraints are specializations of this class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
Callable
|
Callable |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
available_columns
|
list[str] | None
|
Accepted for interface compatibility with row constraints; not used by column constraints. |
None
|
entity
|
str | None
|
Accepted for interface compatibility with row constraints; not used by column constraints. |
None
|
lower_bound
|
int | float
|
Lower bound of the interval. Defaults to |
-inf
|
upper_bound
|
int | float
|
Upper bound of the interval. Defaults to |
inf
|
closed
|
str
|
Which bounds are inclusive: |
'right'
|
Example
Interval(check=numpy.median, columns="age", lower_bound=30, upper_bound=45)
validate(dataset)
Validate the constraint against a dataset.
Evaluates the check on the full column (no sampling).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Dataset to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pdDataFrame |
DataFrame
|
One row with one boolean per constrained column, |
Equal
ydata.constraints.columns.constraint.Equal
Bases: Interval
Check that a statistic of each column equals a value, within a tolerance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
Callable
|
Callable |
required |
value
|
int | float
|
Expected value of the statistic. |
required |
tolerance
|
int | float
|
Allowed absolute deviation from |
0
|
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Example
Equal(check=numpy.mean, value=0.5, tolerance=0.05, columns="rate")
GreaterThan
ydata.constraints.columns.constraint.GreaterThan
Bases: Interval
Check that a statistic of each column is strictly greater than a value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
Callable
|
Callable |
required |
value
|
int | float
|
The statistic must be greater than this value. |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Example
GreaterThan(check=numpy.min, value=0, columns="amount")
LowerThan
ydata.constraints.columns.constraint.LowerThan
Bases: Interval
Check that a statistic of each column is lower than or equal to a value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
Callable
|
Callable |
required |
value
|
int | float
|
Maximum allowed value of the statistic (inclusive). |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
Example
LowerThan(check=numpy.max, value=120, columns="age")
ColumnCustomConstraint
ydata.constraints.columns.constraint.ColumnCustomConstraint
Bases: ColumnConstraint
Check a user-defined condition on each column as a whole.
The callable receives the full column as a pandas.Series and returns a
boolean: True when the column satisfies the condition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
Callable
|
Callable |
required |
columns
|
str | list[str] | None
|
Column(s) to check. |
None
|
name
|
str | None
|
Human-readable label shown in engine summaries. |
None
|
available_columns
|
list[str] | None
|
Accepted for interface compatibility with row constraints; not used by column constraints. |
None
|
entity
|
str | None
|
Accepted for interface compatibility with row constraints; not used by column constraints. |
None
|
Example
ColumnCustomConstraint(check=lambda s: s.is_monotonic_increasing, columns="date")
validate(dataset)
Validate the constraint against a dataset.
Evaluates the check on the full column (no sampling).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Dataset to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pdDataFrame |
DataFrame
|
One row with one boolean per constrained column, |