Expect the paired values from columns A and B to belong to a set of valid pairs.
expect_column_pair_values_to_be_in_set
This expectation level is PRODUCTION
Contributors:
Tags:
core expectation
column pair map expectation
Metrics:
column_pair_values.in_set.unexpected_count
table.row_count
column_pair_values.in_set.filtered_row_count
column_pair_values.in_set.unexpected_values
Description
Expect the paired values from columns A and B to belong to a set of valid pairs.
expect_column_pair_values_to_be_in_set is a Column Pair Map Expectation.
For example:
>>> d = {'fruit': ['appple','apple','apple','banana','banana'],
'color': ['red','green','yellow','yellow','red']}
>>> my_df = pd.DataFrame(data=d)
>>> my_df.expect_column_pair_values_to_be_in_set(
'fruit',
'color',
[
('apple','red'),
('apple','green'),
('apple','yellow'),
('banana','yellow'),
]
)
{
"success": false,
"meta": {},
"exception_info": {
"raised_exception": false,
"exception_traceback": null,
"exception_message": null
},
"result": {
"element_count": 5,
"unexpected_count": 1,
"unexpected_percent": 20.0,
"partial_unexpected_list": [
[
"banana",
"red"
]
],
"missing_count": 0,
"missing_percent": 0.0,
"unexpected_percent_total": 20.0,
"unexpected_percent_nonmissing": 20.0
}
}
Args:
- column_A (str): The first column name
- column_B (str): The second column name
- value_pairs_set (list of tuples): All the valid pairs to be matched
Keyword Args:
- ignore_row_if (str): "both_values_are_missing", "either_value_is_missing", "neither"
Other Parameters:
- result_format (str or None): Which output mode to use: BOOLEAN_ONLY, BASIC, COMPLETE, or SUMMARY. For more detail, see result_format.
- include_config (boolean): If True, then include the expectation config as part of the result object.
- catch_exceptions (boolean or None): If True, then catch exceptions and include them as part of the result object. For more detail, see 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 meta.
Returns:
Exact fields vary depending on the values passed to result_format, include_config, catch_exceptions, and meta.
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