Create a list including row name, column name and the value from dataframe
I feel like make the index
and value different should be more clear
[*df.stack().iteritems()]
[(('A', 'A'), 1), (('A', 'B'), 3), (('A', 'C'), 0), (('B', 'A'), 3), (('B', 'B'), 2), (('B', 'C'), 5), (('C', 'A'), 0), (('C', 'B'), 5), (('C', 'C'), 4)]
Or
df.reset_index().melt('index').values.tolist()
IIUC, you can do:
df.stack().reset_index().agg(tuple,1).tolist()
[('A', 'A', 1),
('A', 'B', 3),
('A', 'C', 0),
('B', 'A', 3),
('B', 'B', 2),
('B', 'C', 5),
('C', 'A', 0),
('C', 'B', 5),
('C', 'C', 4)]