[Solved] Make list of 2-value tuples of all possible combinations of another list


Update: Now the situation looks a bit different as you updated the question. Here’s a quick snippet thrown together using pandas and numpy (for the sake of simplicity we replace missing ratings with zero):

import numpy as np
importport pandas as pd
from itertools import combinations

df = pd.DataFrame(critics).T.fillna(0)

Sample data

distances = []
for critic1, critic2 in combinations(df.index, 2):
    ratings1 = df.ix[critic1].values
    ratings2 = df.ix[critic2].values
    dist = np.sqrt(np.sum(ratings1 - ratings2) ** 2) # euclidian distance
    distances.append((dist, critic1, critic2))

pd.DataFrame(distances, columns=['distance', 'critic1', 'critic2']).sort('distance', ascending=False).head(5)

critics

So there you have it. Gene Seymour and Toby strongly disagree with their ratings.

2

solved Make list of 2-value tuples of all possible combinations of another list