来自熊猫的循环词典

时间:2018-03-09 12:25:02

标签: python pandas dictionary for-loop itertools

我正在尝试从Pandas表创建ts字典,但我无法实现它。

我的表:

         Bool       name       station_id           Coords
0        True       item1          1        19.28152437,47.78960029
1        True       item2          2        20.15190158,46.25528206

我想要的输出:

a= {
    'item1':[ 19.28152437,47.78960029],
    'item2':[20.15190158,46.25528206],
}

我正在使用它来执行此操作:

for i, c in allomasok.iterrows():
     //here is the problem, I can't add name of the dict item 

1 个答案:

答案 0 :(得分:0)

您可以将"autoload": { "psr-4": { "App\\": "src/" } }, pd.DataFrame.set_index结合使用:

pd.DataFrame.to_dict
相关问题