Sometimes, while working with Python Matrix, we can have a problem in which we need to check if an element is present or not. This problem is simpler, but a variation to it can be to perform a check in particular column of Matrix. Let’s discuss a shorthand by which this task can be performed.
Method : Using
any() + list comprehension
This task can be performed using combination of above functions in which we imply list comprehension for iteration and support tasks and
any() can be used to check for any occurrence of the desired character.
The original list : [[1, 4, 5], [6, 7, 8], [8, 3, 0]] Does element exists in particular column : True
- Python | Search in Nth column in list of tuples
- Python | Max/Min value in Nth Column in Matrix
- Python | Nth Column vertical string in Matrix
- Python | Nth column Matrix Product
- Python - Extract ith column values from jth column values
- Python - Get maximum of Nth column from tuple list
- Python - Get Nth column elements in Tuple Strings
- Python - Constant Multiplication to Nth Column
- Python - Remove Record if Nth Column is K
- Create a DataFrame from a Numpy array and specify the index column and column headers
- Get column index from column name of a given Pandas DataFrame
- Create a Pandas DataFrame from a Numpy array and specify the index column and column headers
- Python Program for Anagram Substring Search (Or Search for all permutations)
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Python | Get Kth Column of Matrix
- Python - Summation of kth column in a matrix
- Python - Remove front column from Matrix
- Python | Matrix Tuple pair Column product
- Python | Uneven Sized Matrix Column product
- Python - Uneven Sized Matrix Column Minimum
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.