def filter_data(data, predicate=lambda k, v: True):
    for d in data:
        for k, v in list(d.items()):
            if predicate(k, v):
                yield d
test_data = [{'key1': 'value1', 'key2': 'value2'}, {'key1': 'blabla'}, {
    'key1': 'value1', 'eh': 'uh'}]
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python?