I have a list of tuples: a = [(1,2),(1,4),(1,2),(6,7),(2,9)] I want to check if one of the individual elements of each tuple matches the same position/element i
a = [(1,2),(1,4),(1,2),(6,7),(2,9)]
Using pandas this is simple and very fast:
import pandas print(pandas.Series(data=[(1,2),(1,4),(1,2),(6,7),(2,9)]).value_counts()) (1, 2) 2 (1, 4) 1 (6, 7) 1 (2, 9) 1 dtype: int64