unique, idx = np.unique(matches[:, (0), (1)], return_inverse=True)
How to retrieve frequencies of the number of unique occurrences of pair letters for every possible pair of columns from a numpy matrix in python