import itertools
column = [3, 1, 7, 2, 9, 4]
You can make a set of pairs like this
# You can use set() instead of list() if you want to remove duplicates
list(itertools.combinations(column,2))
Output
[(3, 1), (3, 7), (3, 2), (3, 9), (3, 4),
(1, 7), (1, 2), (1, 9), (1, 4),
(7, 2), (7, 9), (7, 4),
(2, 9), (2, 4),
(9, 4)]
Then you can get the sum of differences using a list comprehension
sum([abs(pair[1] - pair[0]) for pair in itertools.combinations(column,2)])
Output
56