Use DataFrame.unstack
for reshape, then convert Series
to DataFrame
and last convert nested lists to tuples:
L = [tuple(x) for x in df.unstack().reset_index().to_numpy()]
Or:
L = list(map(tuple, df.unstack().reset_index().to_numpy()))
Another idea, thank you @Datanovice:
L = list(df.unstack().reset_index().itertuples(name=None,index=None))
print (L)
[('A', 'D', 0.78), ('A', 'E', 0.93), ('B', 'D', 0.49), ('B', 'E', 0.67)]
If order should be swapped, thank you @Ch3steR:
L = list(df.reset_index().melt(id_vars='index').itertuples(name=None,index=None))
print (L)
[('D', 'A', 0.78), ('E', 'A', 0.93), ('D', 'B', 0.49), ('E', 'B', 0.67)]