Potential New Check: has_n_values
ZaxR opened this issue · 1 comments
ZaxR commented
def has_n_values(df, items):
"""Has exactly n unique values in specified columns."""
cols_n_unique = {col: df[col].nunique() for col in list(items.keys())}
bad_cols = [col for col, n_unique in items.items() if cols_n_unique[col] != n_unique]
if bad_cols:
raise AssertionError(f"The following columns have a different number of unique items than expected: "
f"{', '.join(bad_cols)}")
ZaxR commented
Can use the following for the tests: pandas-dev/pandas#28202