擅长:python、mysql、java
<p>创建列表列表,然后使用pd.数据帧(数据、列)似乎是最简单的选择。你知道吗</p>
<pre><code># First calculate the length of maximum list in the dictionary
# Let that be lmax
data = []
for elem in dict :
for key in elem : # Note that only one key is there
lst = elem[key] # z is the list
data_curr = [np.nan] * (3*len(lmax) + 1)
data_curr[0] = elem
l = len(lst[0])
for i in range(0,l) :
data_curr[3*i+1] = z[0][i]
data_curr[3*i+2] = z[1][i]
data_curr[3*i+3] = z[2][i]
data.append(data_curr]
columns = ['key','List1-1,List1-2','List1-3','List2-1','List2-2','List2-3','List3-1','List3-2','List3-3']
df = pd.DataFrame(data,columns=columns)
</code></pre>
<p>我希望你能明白</p>