I have a dataframe that looks like this:
start stop duration
0 1 2 1
1 3 4 2
2 2 1 2
3 4 3 0
I'm trying to build a dictionary with key= (start, stop) pairs and the value= avg of their duration, regardless of the order. In other words, (1,2) and (2,1) would both count as an occurrence of the pair (1,2).
Desired output: dict_avg= {(1,2):1.5, (3,4):1}
What's the best way to achieve this?