python pandas - Editing multiple DataFrames with a for loop

前端 未结 6 741
误落风尘
误落风尘 2021-01-06 18:30

Considering the following 2 lists of 3 dicts and 3 empty DataFrames

dict0={\'actual\': {\'2013-02-20 13:30:00\': 0.93}}
dict1={\'actual\': {\'2013-02-20 13:3         


        
6条回答
  •  广开言路
    2021-01-06 19:14

    I don't have an explanation for why that is so. However a workaround is:

    dict0={'actual': {'2013-02-20 13:30:00': 0.93}}
    dict1={'actual': {'2013-02-20 13:30:00': 0.85}}
    dict2={'actual': {'2013-02-20 13:30:00': 0.98}}
    dicts=[dict0, dict1, dict2]
    
    dfs = []
    
    for dikt in dicts:
        df = df.from_dict(dikt, orient='columns', dtype=None)
        dfs.append(df)
    

    Now

    dfs[0]
    

    returns

                         actual
    2013-02-20 13:30:00    0.93
    

提交回复
热议问题