I want to compare every element of the list to the rest of the elements. For this, I need to iteratively exclude one element. Specifically, I want to calculate the mean of all elements when one value is removed. E.g.:
mylist = [1, 2, 3, 4]
Mean values:
[2, 3, 4] = 3 (excludes 1)
[1, 3, 4] = 2.66 (excludes 2)
[1, 2, 4] = 2.44 (excludes 3)
[1, 2, 3] = 2 (excludes 4)
Is there an intuitive way of doing this, without something like
[mylist[i-1:i] + mylist[i+1:] for i in range(len(mylist))]?