Convert Python dict into a dataframe

前端 未结 16 2379
暗喜
暗喜 2020-11-22 03:18

I have a Python dictionary like the following:

{u\'2012-06-08\': 388,
 u\'2012-06-09\': 388,
 u\'2012-06-10\': 388,
 u\'2012-06-11\': 389,
 u\'2012-06-12\':          


        
16条回答
  •  既然无缘
    2020-11-22 03:52

    I think that you can make some changes in your data format when you create dictionary, then you can easily convert it to DataFrame:

    input:

    a={'Dates':['2012-06-08','2012-06-10'],'Date_value':[388,389]}
    

    output:

    {'Date_value': [388, 389], 'Dates': ['2012-06-08', '2012-06-10']}
    

    input:

    aframe=DataFrame(a)
    

    output: will be your DataFrame

    You just need to use some text editing in somewhere like Sublime or maybe Excel.

提交回复
热议问题