I have a dataframe that stores the distances between three objects:
<code>df = pd.DataFrame({'obj1': ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
'obj2': ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'],
'dist': [0, 1, 2, 1, 0, 3, 2, 3, 0]})
</code>
<code>df = pd.DataFrame({'obj1': ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
'obj2': ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'],
'dist': [0, 1, 2, 1, 0, 3, 2, 3, 0]})
</code>
df = pd.DataFrame({'obj1': ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
'obj2': ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'],
'dist': [0, 1, 2, 1, 0, 3, 2, 3, 0]})
Is there a way I can compute the object that has the min distance for each obj1
other than itself? For the example above return [('a', 'b', 1), ('b', 'a', 1), ('c', 'a', 2)]
.