【发布时间】:2018-08-18 00:39:07
【问题描述】:
我正在尝试从 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],
}
我正在使用 iterrows 来做到这一点:
for i, c in allomasok.iterrows():
//here is the problem, I can't add name of the dict item
【问题讨论】:
-
字典
a列表中的值在上面的示例中不存在。b是字典列表,而不是字典本身。你能澄清你的问题,也许可以把它背景化吗?如果你想使用不可变的可迭代对象,你可以尝试使用元组 -
我更正了,抱歉我的错字。
标签: python pandas dictionary for-loop itertools