Use a list comprehension:

[y for x,y in A if x>2]

Demo:

>>> A=[(1,'A'),(2,'H'),(3,'K'),(4,'J')]
>>> [y for x,y in A if x>2]
['K', 'J']
>>> 
Answer from U13-Forward on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_filter.asp
NumPy Filter Array
A boolean index list is a list of booleans corresponding to indexes in the array. If the value at an index is True that element is contained in the filtered array, if the value at that index is False that element is excluded from the filtered array.
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ filtering-arrays
NumPy Filtering Arrays
In this syntax, condition is a boolean array that determines which elements from array are included in filtered_array.
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ numpy filter array by condition | example code
NumPy filter array by condition | Example code
May 16, 2022 - Answer: Use boolean indexing to filter elements in an array by value to filter NumPy Array. import numpy as np na = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) res = na[na > 4] print(res) ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-filtering-rows-by-multiple-conditions
NumPy - Filtering rows by multiple conditions - GeeksforGeeks
October 10, 2022 - # importing numpy lib import numpy as np # making a numpy array arr = np.array([x for x in range(11, 40)]) print("Original array") print(arr) # making a blank list new_arr = [] for x in arr: # applying two conditions: number is divisible by 2 and is greater than 15 if x % 2 == 0 and x > 15: new_arr.append(x) # Converting new list into numpy array new_arr = np.array(new_arr) print("New array") print(new_arr) ... # importing numpy lib import numpy as np # making a numpy array arr = np.array([x for x in range(11, 40)]) print("Original array") print(arr) # using lambda to apply condition new_arr = list(filter(lambda x: x > 15 and x % 2 == 0 and x % 10 != 0, arr)) # Converting new list into numpy array new_arr = np.array(new_arr) print("New array") print(new_arr)
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ filter
Python filter(): Syntax, Usage, and Examples
You should reach for filter() when you want to streamline conditional selection. It's especially useful for: Keeping only valid data entries from a list or array ... Instead of managing temporary lists and for loops manually, you express your filtering logic in one line. This approach is similar to filtering in other languages like Java or SQL, but with Python's more concise syntax.
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to filter a list in python?
How to Filter a List in Python? - Be on the Right Side of Change
July 14, 2022 - How can you filter a list in Python using an arbitrary condition? The most Pythonic and most performant way is to use list comprehension [x for x in list if condition] to filter all elements from a list.
๐ŸŒ
Python Guides
pythonguides.com โ€บ python-numpy-filter
How To Filter NumPy 2D Array By Condition In Python
May 16, 2025 - Boolean indexing is the easiest way to filter a 2D array in Python NumPy. It works by creating a mask of True/False values and using it to select elements. Letโ€™s create a simple 2D array representing sales data for different store locations:
Find elsewhere
๐ŸŒ
Data Science Parichay
datascienceparichay.com โ€บ home โ€บ blog โ€บ filter a numpy array โ€“ with examples
Filter a Numpy Array - With Examples - Data Science Parichay
June 17, 2022 - To filter the array on multiple conditions, you can combine the conditions together using parenthesis () and the โ€œandโ€ & operator โ€“ ((condition1) & (condition2) & ...) Letโ€™s filter the array โ€œarrโ€ on two conditions โ€“ greater than ...
๐ŸŒ
ProjectPro
projectpro.io โ€บ recipes โ€บ filter-numpy-array-based-on-two-or-more-conditions
How to filter a numpy array based on two or more conditions? -
May 25, 2022 - How to filter a numpy array based on two or more conditions? Creating a new array from the existing array whereas taking out some elements from that existing array and then creating a new one is called as filtering.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-filter-two-dimensional-numpy-array-based-on-condition
How to filter two-dimensional NumPy array based on condition ? - GeeksforGeeks
July 23, 2025 - To filter we used this fltr in numpy.in1d() method and stored as its values in the original array that return True if condition fulfills.
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ python filter list by condition
Python filter list by condition - Tutorial - By EyeHunts
January 13, 2023 - numbers = [25, 24, 26, 45, 25, 23, 50, 51] filtred = list(filter(lambda x: x > 25, numbers)) print(filtred) print(type(filtred)) ... Another way is to create an empty list, iterate through the current list and append all relevant items to the new list, like so: numbers = [25, 24, 26, 45, 25, 23, 50, 51] new_list = [] for i in numbers: if 25 <= i <= 50: new_list.append(i) print(new_list) Do comment if you have any doubts or suggestions on this Python filter topic.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to filter a numpy array (4 examples)
How to Filter a NumPy Array (4 Examples)
July 9, 2022 - Note: You can find the complete documentation for the NumPy in1d() function here. The following tutorials explain how to perform other common filtering operations in Python: How to Filter Pandas DataFrame Rows that Contain a Specific String ...
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ numpy โ€บ numpy filter elements in array
How to Filter Elements in a NumPy Array | Delft Stack
February 2, 2024 - This article will introduce how ... as an argument. We can apply conditions to the input array elements and further give that new array to this function to get the desired elements in a NumPy array....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ filter-in-python
filter() in python - GeeksforGeeks
filter() function is used to extract elements from an iterable (like a list, tuple or set) that satisfy a given condition. It works by applying a function to each element and keeping only those for which function returns True.
Published: March 18, 2026
๐ŸŒ
KDnuggets
kdnuggets.com โ€บ 2022 โ€บ 11 โ€บ 5-ways-filtering-python-lists.html
5 Ways of Filtering Python Lists - KDnuggets
November 14, 2022 - It is easy to write, and you can even add multiple if-else conditions without an issue. Learn list comprehension with code examples by reading When to Use a List Comprehension in Python. scores = [200, 105, 18, 80, 150, 140] filtered_scores = [s for s in scores if s >= 150] print(filtered_scores)
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ numpy โ€บ numpy_filtering_arrays.htm
NumPy - Filtering Arrays
Boolean indexing allows you to filter array elements based on conditions. By applying a condition to an array, you obtain a Boolean array that you can use to index the original array.
๐ŸŒ
IONOS
ionos.com โ€บ digital guide โ€บ websites โ€บ web development โ€บ python filter function
What is Python's filter function and how to use it - IONOS
May 26, 2025 - Pythonโ€™s filter() function allows you to filter an iterable using a condition. Python then creates a new iterator that only includes the elements that meet the specified condition.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ filter elements from python list
Filter Elements from Python List - Spark By {Examples}
May 31, 2024 - The filter() function in Python is used to filter the elements from the list. Let's discuss this filter() method by providing different parameters like