python pandas - Editing multiple DataFrames with a for loop

前端 未结 6 736
误落风尘
误落风尘 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:01

    One liner.

    >>>df_list = [df.from_dict(dikt, orient='columns', dtype=None) for (df, dikt) in zip(dfs, dicts)]
    
    >>>df_list
    [                     actual
    2013-02-20 13:30:00    0.93,
                          actual
    2013-02-20 13:30:00    0.85, 
                          actual
    2013-02-20 13:30:00    0.98]
    
    >>>df_list[0]
                         actual
    2013-02-20 13:30:00    0.93
    

提交回复
热议问题