Sometimes, while working with python list, we can have a binary matrix ( Nested list having 2 elements ). And we can have a problem in which we need to find the uniqueness of a pair. A pair is unique irrespective of order, it doesn’t appear again in list. Let’s discuss certain way in which this task can be performed.
Method : Using
frozenset() + Counter() + list comprehension
The combination of above functions can perform this task. The
frozenset() is used for ignoring the ordering,
Counter() is used to perform the task of checking the uniqueness and iteration is done using list comprehension.
The original list is : [[5, 6], [9, 8], [8, 9], [1, 4], [6, 5], [10, 1]] The Unique status of elements is [False, False, False, True, False, True]
- Python | Assign ids to each unique value in a list
- Python | Get unique tuples from list
- Python | Get unique values from a list
- Python | Count unique sublists within list
- Python | Check if list contains all unique elements
- Python | Assign value to unique number in list
- Python | Get Unique values from list of dictionary
- Python | Unique dictionary filter in list
- Python | Make pair from two list such that elements are not same in pairs
- Python program to find sum of absolute difference between all pairs in a list
- Given two arrays, find n+m-1 unique sum pairs
- Python | Pandas TimedeltaIndex.unique()
- Python | Unique values in Matrix
- Python | Pandas Series.unique()
- Python | Pandas Index.unique()
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.