What is the most efficient way to convert a pandas dataframe with each individual rows like this:
p1 p2 prog
0 A B C
into 3 lines like this?
n1 n2 edge_type
0 A A/B marriage
1 B A/B marriage
2 A/B C child
or equivalently, converting df to DF as follows:
df = pd.DataFrame({'prog':['C'], 'p1': ['A'], 'p2': ['B']})
dF = pd.DataFrame({'edge_type':['marriage', 'marriage', 'child'], 'n1': ['A', 'B', 'A/B'], 'n2': ['A/B', 'A/B', 'C']})
It is straightforward with defining a worker function and use mapply in R, but I am still scratching my head on doing that in Python.
