Convert pandas dataframe to list of tuples - ('Row', 'Column', Value)

后端 未结 3 1505
谎友^
谎友^ 2021-01-07 12:17

There are a few other questions regarding the same subject, but the format desired is different in all.

I am trying to build a heatmap visualization using holoviews

3条回答
  •  北海茫月
    2021-01-07 13:01

    With iterators and list comprehention:

    my_list = []
    for row in df.iterrows():
        my_list.extend([(row[0], i, v) for i, v in row[1].iteritems()])
    

提交回复
热议问题