Convert Python dict into a dataframe

前端 未结 16 2571
暗喜
暗喜 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 04:05

    You can also just pass the keys and values of the dictionary to the new dataframe, like so:

    import pandas as pd
    
    myDict = {]
    df = pd.DataFrame()
    df['Date'] = myDict.keys()
    df['DateValue'] = myDict.values()
    

提交回复
热议问题