Pandas data frame to dictionary of lists

前端 未结 2 898
情歌与酒
情歌与酒 2020-12-11 02:32

How to use python or pandas (preferably) to convert a pandas data_frame to dictionary of lists for input into highcharts.

The closest I got to was (see tmp notebook

2条回答
  •  感情败类
    2020-12-11 02:53

    to create a list of the dictionaries per line

    post_data_list = []
    for i in df2.index:
      data_dict = {}
      for column in df2.columns:
        data_dict[column] = df2[column][i]
      post_data_list.append(data_dict)
    

提交回复
热议问题