I have a python dataframe with distances listed as follows
dict = {'from' : ['A','A','A','B','B','D','D','D'],
'to' : ['B','C','D','C','E','B','C','E'],
'distances': [4,3,1,1,3,4,2,9]}
df = pd.DataFrame.from_dict(dict)
I want enumerate all of the Distances for:
From point1 == > point2
where point1==> point2 = From point1 ==> B + From B==> point2 and is included in the a
how can i do this efficiently using python - i assume some kind of pd.merge?
I would then like to reformate the dataframe into the following
columns = ['From','To','Distance','Distance via B']