【发布时间】:2019-03-20 00:31:39
【问题描述】:
我有一个列表字典,就像 -
from collections import defaultdict
defaultdict(list,
{'row1': ['Affinity'],
'row2': ['Ahmc',
'Garfield',
'Medical Center'],
'row3': ['Alamance','Macbeth'],
'row4': [],
'row5': ['Mayday']})
我想将其转换为数据框。 输出应该看起来像-
ID SYN1 SYN2 SYN3 SYN4 SYN5
row1 Affinity
row2 Ahmc Garfield Medical Center
row3 Alamance Macbeth
row4
row5 Mayday
【问题讨论】:
-
你能解释一下“值的可变长度是变化的”是什么意思吗?
-
听到“第 2 行”包含 3 个值。而“第 1 行”只有 1 个。
标签: python python-3.x pandas dictionary