Expect column entries to be strings with length between a minimum value and a maximum value (inclusive).
expect_column_value_lengths_to_be_between
This expectation level is PRODUCTION
Contributors:
Tags:
Backend support:#
Description#
Class Name:
ExpectColumnValueLengthsToBeBetween
Short Description:
Expect column entries to be strings with length between a minimum value and a maximum value (inclusive).
Docstring:
Expect column entries to be strings with length between a minimum value and a maximum value (inclusive).
This expectation only works for string-type values. Invoking it on ints or floats will raise a TypeError.
expect_column_value_lengths_to_be_between is a :func:column_map_expectation <great_expectations.execution_engine.execution_engine.MetaExecutionEngine .column_map_expectation>
.
Args:
- column (str): The column name.
- min_value (int or None): The minimum value for a column entry length.
- max_value (int or None): The maximum value for a column entry length.
Keyword Args:
- mostly (None or a float between 0 and 1): Return
"success": True
if at least mostly fraction of values match the expectation. For more detail, see :ref:mostly
.
Other Parameters:
- result_format (str or None): Which output mode to use:
BOOLEAN_ONLY
,BASIC
,COMPLETE
, orSUMMARY
.
For more detail, see :ref:result_format <result_format>
. - include_config (boolean): If True, then include the expectation config as part of the result object. For more detail, see :ref:
include_config
. - catch_exceptions (boolean or None): If True, then catch exceptions and include them as part of the result object. For more detail, see :ref:
catch_exceptions
. - meta (dict or None): A JSON-serializable dictionary (nesting allowed) that will be included in the output without modification. For more detail, see :ref:
meta
.
Returns:
An ExpectationSuiteValidationResult
Exact fields vary depending on the values passed to :ref:result_format <result_format>
and
:ref:include_config
, :ref:catch_exceptions
, and :ref:meta
.
Notes:
- min_value and max_value are both inclusive.
- If min_value is None, then max_value is treated as an upper bound, and the number of acceptable rows has no minimum.
- If max_value is None, then min_value is treated as a lower bound, and the number of acceptable rows has no maximum.
See Also:
-
:func:
expect_column_value_lengths_to_equal <great_expectations.execution_engine.execution_engine.ExecutionEngine.expect_column_value_lengths_to_equal>
Renderers#
We have yet to add renderers to this expectation.
Examples#
s1 | s2 | s3 | s4 |
---|---|---|---|
smart | cool | cool | 1 |
silly | calm | calm | 2 |
sassy | collected | collected | 3 |
slimy | casual | casual | 4 |
sexy | creepy | 5 |
Tests
positive_test_exact_min_and_max
Input:
column: s1,
min_value: 4,
max_value: 5,
}
Output:
success: true,
unexpected_index_list: ,
unexpected_list: ,
}
s1 | s2 | s3 | s4 |
---|---|---|---|
smart | cool | cool | 1 |
silly | calm | calm | 2 |
sassy | collected | collected | 3 |
slimy | casual | casual | 4 |
sexy | creepy | 5 |
Want to make your own Expectation or an improvement to this one?
We've put together some great how to guides (including videos) on how to create your own expectations in a flash!
You can see those resources here: Contributor Resources