小编bah*_*har的帖子

从字典创建 DataFrame,其中字典的值为 numpy 数组

我想从字典创建一个数据框,其中的值是 2D numpy 数组。

my_Dict={'a': array([[1, 2, 3],[4, 5, 6]]), 'b': array([[7,8,9],[10,11,12]]),'c': array([[13,14,15],[16,17,18]])}
Run Code Online (Sandbox Code Playgroud)

我希望结果是一个包含 2 行(numpy 数组中的行数)和 3 列的数据框,如下所示:

       a         b          c

0  [1, 2, 3]   [7,8,9]    [13,14,15]

1  [4, 5, 6]  [10,11,12] [16,17,18]
Run Code Online (Sandbox Code Playgroud)

我尝试更改要列出的值并且它有效。但我想将这些值保留为 np 数组,以便将 numby 函数应用于这些值。

python dictionary

5
推荐指数
1
解决办法
4956
查看次数

标签 统计

dictionary ×1

python ×1