Maybe consider the following?
Check a column in a dataframe to make sure all values are greater/lower/equal/ge/le/ than a specific value(not a range).
import operator
def compare_with_value(df, columns, value, which_operator):
if any(which_operator(column_value, value) for column_value in df[columns].values):
raise AssertionError
return df
Used with a MultiCheck decorator:
@dc.MultiCheck(checks={ck.has_no_nans: {"columns": "test_column"},
compare_with_value: {"columns": "test_column",
"which_operator": operator.le,
"value": 10.0
}
}
)
Also, in case it helps anyone:
I tried has_vals_within_range() following this format (i.e. as has_no_nans()):
ck.has_vals_within_range: {"columns": "test_column"}
but it seems that it needs an items element instead (see below).
ck.has_vals_within_range: {"items": {"test_column": (2, 50)}}
I am just mentioning here as it's minor, but maybe consider renaming "items" to "columns" just for consistency?
Maybe consider the following?
Check a column in a dataframe to make sure all values are greater/lower/equal/ge/le/ than a specific value(not a range).
Used with a MultiCheck decorator:
Also, in case it helps anyone:
I tried has_vals_within_range() following this format (i.e. as has_no_nans()):
but it seems that it needs an items element instead (see below).
I am just mentioning here as it's minor, but maybe consider renaming "items" to "columns" just for consistency?