I have a tall (3,000,000 by 2) matrix, represented as a list of lists (A list with 3 million elements, each being a list with two elements) and I need to count the number of times each pair appears as a row (there's a finite number of possible pairs, around 5000). This is what I do so far, but it's highly inefficient:
for a in list1:
for b in list2:
count_here = tall_matrix.count([a,b])
Any ideas on how to make this quicker?
Thanks a lot!