I am trying to form all possible pathways using a dataframe. I have the following dataframe:
import pandas as pd
data = {'from': ['b','c','d','e','f','g'], 'to': ['a', 'a', 'a', 'b','c','e']}
df = pd.DataFrame.from_dict(data)
print(df)
sample dataframe

Now, I want to make all possible pathways/chain using these 2 columns.Output should look something like this:
- e -> b -> a
- f -> c -> a
- g -> e -> b -> a
If possible, then representing them with numbers like:
- e -> b -> a = 5,2,1
- f -> c -> a = 6,3,1
- g -> e -> b -> a = 7,5,2,1
Update: From field can contain duplicate entries.