Count all unique triples
Suppose that I have a pandas data frame A with columns called user_id and history where history is an array of ints. And the possible histories are bounded from above by 2000. I need to iterate through all rows of A, for each history b = [b1, b2, b3, …, bn]. All bi’s are unique(only appearing once in the array). I need to find all possible triples (bi, bj, bk) such that i < j < k, and count the occurrences of all such triples.