def validate_key_attr(key_attr, table, table_label):
    """Check if the attribute is a valid key attribute."""
    unique_flag = len(table[key_attr].unique()) == len(table)
    nan_flag = sum(table[key_attr].isnull()) == 0
    if not (unique_flag and nan_flag):
        raise AssertionError("'" + key_attr + "' is not a key attribute " +
            'in ' + table_label)
    return True
