for i, j in itertools.combinations(list(range(len(s.T))), 2):
    c = s[:, ([i, j])]
counts = collections.Counter(map(tuple, c))
print('columns {} and {}'.format(i, j))
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