【发布时间】:2021-06-18 20:11:38
【问题描述】:
我有这本词典(pred)。字典包含 numpy 数组。
pred.keys()
dict_keys([0, 1]) #keys of the dictionary
pred.values() #### values of the array nested in dictionary
dict_values([array([[0.],
[0.],
[0.],
...,
[0.],
[0.],
[0.]], dtype=float32), array([[0.],
[0.],
[0.],
...,
[0.],
[0.],
[0.]], dtype=float32)])
I want to convert it into a data frame with each column showing the values of array for the dictionary key
【问题讨论】:
-
你可以试试
pd.concat({k: pd.DataFrame(v) for k, v in pred.items()}, axis=1)吗? -
@jerael.. 非常感谢您救命
-
超级,添加到答案中。
标签: python arrays pandas dictionary multidimensional-array