You can use a dict comprehension:

{k: v for k, v in points.items() if v[0] < 5 and v[1] < 5}

And in Python 2, starting from 2.7:

{k: v for k, v in points.iteritems() if v[0] < 5 and v[1] < 5}
Answer from Thomas on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › filter-list-of-python-dictionaries-by-key-in-python
Filter List of Python Dictionaries by Key in Python - GeeksforGeeks
July 23, 2025 - Let's explore some more methods and see how we can filter list of Python dictionaries by key in Python. ... filter() function can also be used to filter dictionaries based on a key. This method requires converting the result to a list.
Discussions

How to filter through a dictionary returning a list of key objects?
You don’t want a dictionary comprehension, you want a list comprehension. You can’t return in a list comprehension, but you can return a list comprehension. Lambdas don’t even have returns. lambda d: [key[-2:] for key in d.keys()] You could also do the following, but I think the first is more explicit. lambda d : [key[-2:] for key in d] More on reddit.com
🌐 r/learnpython
3
1
June 9, 2021
filter items in a python dictionary where keys contain a specific string - Stack Overflow
I'm a C coder developing something in python. I know how to do the following in C (and hence in C-like logic applied to python), but I'm wondering what the 'Python' way of doing it is. I have a More on stackoverflow.com
🌐 stackoverflow.com
Filtering a dictionary value from a list of dictionary using lambda and filter in python - Stack Overflow
I want to get the value of the dictionary that has the key 'Name' Initially I wrote a function as below: def get_json_val(l, key): for item in l: for k, v in item.iteritems(): if k == key: return v · But I want to do it using lambdas and filter in a single line. More on stackoverflow.com
🌐 stackoverflow.com
January 11, 2018
python filter list of dictionaries based on key value - Stack Overflow
I have a list of dictionaries and each dictionary has a key of (let's say) 'type' which can have values of 'type1', 'type2', etc. My goal is to filter out these dictionaries into a list of the same More on stackoverflow.com
🌐 stackoverflow.com
🌐
Finxter
blog.finxter.com › home › learn python blog › how to filter a dictionary in python? (… the most pythonic way)
How to Filter a Dictionary in Python? (... The Most Pythonic Way) - Be on the Right Side of Change
October 9, 2022 - The lambda function you pass returns k%2 == 1 which is the Boolean filtering value associated with each original element in the dictionary names. Similarly, if you want to filter by key to include only even keys, do the following:
🌐
LearnPython.com
learnpython.com › blog › filter-dictionary-in-python
How to Filter a Python Dictionary | LearnPython.com
December 26, 2022 - Learn how to filter Python dictionaries by keys and values, including using multiple keys and conditions at once.
🌐
GitHub
gist.github.com › 89465127 › 5776892
python filter a dictionary by keys or values · GitHub
@fbens iteritems is gone if you're using python 3. try d.items() instead · Copy link · Copy Markdown · can use this for value search d3 = {k : v for k,v in filter(lambda t: t[1] in [22, 33], d.iteritems())} Sign up for free to join this conversation on GitHub.
🌐
AskPython
askpython.com › python › dictionary › filter-list-of-dictionaries-based-on-key-values
3 Ways to Filter List of Dictionaries Based on Key Values - AskPython
April 27, 2023 - Coming to filtering the dictionary based on the key values, we have seen three approaches. Firstly, we created a list of dictionaries according to the syntax and used list comprehension to set a condition and print the filtered list of dictionaries that satisfy the given condition. This list is then converted to a dictionary. In the second approach, we have used the built-in function –filter and the lambda function to do the same task.
🌐
GeeksforGeeks
geeksforgeeks.org › python-filter-dictionaries-by-values-in-kth-key-in-list
Python – Filter dictionaries by values in Kth Key in list | GeeksforGeeks
March 31, 2023 - Use map() to apply the lambda function to each dictionary in test_list and store the result in a list. Use filter() to filter the dictionaries in the list based on whether d[K] is in search_list.
Find elsewhere
🌐
Python Guides
pythonguides.com › python-dictionary-filter
How to Filter a Dictionary in Python
November 10, 2025 - Learn how to filter a dictionary in Python using conditions, dictionary comprehensions, and lambda functions. Includes clear examples and practical tips.
🌐
Sololearn
sololearn.com › en › Discuss › 3283767 › filter-and-lambda-expressions-with-dictionaries-update-answered
Filter and lambda expressions with dictionaries. Update: Answered | Sololearn: Learn to code for FREE!
July 9, 2024 - but we can use the membership operator `in`. to get it done we can filter for the letter `a` like: ... k_names = dict(filter(lambda item: 'a' in item[1], figures.items())) > result will be: {'chicken': 'Klaartje', 'horse': 'Karel', 'duck': 'Donald'} >> to make the filtering with the dicts a bit more general, we can use input values, store them in a variable,and use this variable instead of the *hardcoded* samples we have been talking so far. ... if you are looking for more complex patterns than startswith(), endswith(), and "in", consider "regular expressions" (not sure if it is covered in the current courses?). ... Lisa , regex is *not* explained in the current available python tutorials.
🌐
Reddit
reddit.com › r/learnpython › how to filter through a dictionary returning a list of key objects?
r/learnpython on Reddit: How to filter through a dictionary returning a list of key objects?
June 9, 2021 -

So let's say I have a dictionary of

dict = { chevy_01 : "Ford", chevy_02: "Tahoe"}

I want to filter through the KEYS of the dict and get the last two characters of the keys while later performing another function. So I imagine something like this

{for keys in vals print (key[-2:]} 

But I want the end of the function to return a list of the last two characters in the dict so it will just return [01, 02].

I want to do this in a lambda function I'm bad at dict comprehension. Can someone help me out?

🌐
GeeksforGeeks
geeksforgeeks.org › python › filter-list-of-dictionaries-based-on-key-values-in-python
Filter List of Dictionaries Based on Key Values in Python - GeeksforGeeks
July 23, 2025 - p = [{'name': 'geek1', 'role': ... # Use filter() with lambda to filter the list based on roles res = list(filter(lambda d: d['role'] in f, p)) print(res) ......
Top answer
1 of 4
238

You can try a list comp

>>> exampleSet = [{'type':'type1'},{'type':'type2'},{'type':'type2'}, {'type':'type3'}]
>>> keyValList = ['type2','type3']
>>> expectedResult = [d for d in exampleSet if d['type'] in keyValList]
>>> expectedResult
[{'type': 'type2'}, {'type': 'type2'}, {'type': 'type3'}]

Another way is by using filter

>>> list(filter(lambda d: d['type'] in keyValList, exampleSet))
[{'type': 'type2'}, {'type': 'type2'}, {'type': 'type3'}]
2 of 4
43

Trying a few answers from this post, I tested the performance of each answer.

As my initial guess, the list comprehension is way faster, the filter and list method is second and the pandas is third, by far.

defined variables:

import pandas as pd

exampleSet = [{'type': 'type' + str(number)} for number in range(0, 1_000_000)]

keyValList = ['type21', 'type950000']


1st - list comprehension

%%timeit
expectedResult = [d for d in exampleSet if d['type'] in keyValList]

60.7 ms ± 188 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

2nd - filter and list

%%timeit
expectedResult = list(filter(lambda d: d['type'] in keyValList, exampleSet))

94 ms ± 328 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

3rd - pandas

%%timeit
df = pd.DataFrame(exampleSet)
expectedResult = df[df['type'].isin(keyValList)].to_dict('records')

336 ms ± 1.84 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)


On a side note, using pandas to deal with a dict is not a great idea since the pandas.DataFrame is basically a more memory consuming dict and if you are not going to use a dataframe in the end it is just inefficient.

🌐
HackerNoon
hackernoon.com › filtering-dictionary-in-python-3-3eb99f92e6ee
Filtering Dictionary In Python 3
Discover Anything · Hackernoon · Signup · Write · Light-Mode · Classic · Newspaper · Minty · Dark-Mode · Neon Noir
🌐
datagy
datagy.io › home › python functions › python filter: a complete guide to filtering iterables
Python filter: A Complete Guide to Filtering Iterables • datagy
December 20, 2022 - In this tutorial, you’ll learn how to use the filter() function to filter items that meet a condition. You’ll learn how to use the function to filter lists, tuples, and dictionaries.
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to filter a list of dictionaries by key value in python
5 Best Ways to Filter a List of Dictionaries by Key Value in Python - Be on the Right Side of Change
February 22, 2024 - If a user’s age is greater than 18, that dictionary is appended to adult_users. This method utilizes Python’s built-in filter() function to filter out items. It’s more concise and idiomatic than a for loop. ... The filter() function applies a lambda function that checks the ‘age’ key to each dictionary in the list, and list() is used to convert the resulting filter object back to a list.
🌐
Medium
medium.com › @muirujackson › set-dictionary-and-lambda-filter-reduce-and-map-functions-4b304a30a0da
Set, Dictionary, and Lambda, filter, reduce and map functions | by Muiru Jackson | Medium
June 14, 2023 - In this article, we explored sets ... dictionaries and their advantages, and delved into lambda functions, map, reduce, and filter functions. These concepts are essential for any Python programmer looking to work with different data structures efficiently and leverage powerful functions to simplify coding tasks. By understanding ...
🌐
CodeRivers
coderivers.org › blog › python-filter-dictionary
Python Filter Dictionary: Unleashing the Power of Data Selection - CodeRivers
February 22, 2026 - Filtering dictionaries in Python is a powerful technique that allows you to extract relevant data based on specific criteria. By using dictionary comprehension, the filter() function, and lambda expressions, you can efficiently filter dictionaries by keys, values, or multiple conditions.