Pandas data frame to dictionary of lists

前端 未结 2 900
情歌与酒
情歌与酒 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:45

    In [199]: df2.reset_index().to_dict(orient='list')
    Out[199]: 
    {'date': ['2014-10-1', '2014-10-2', '2014-10-3', '2014-10-4', '2014-10-5'],
     'foo': [8, 1, 8, 8, 1],
     'temp': [10, 10, 8, 3, 10],
     'time': [1, 2, 3, 4, 5]}
    

提交回复
热议问题