如何在 numpy 二维数组中存储列表?

zub*_*hta 4 python numpy list multidimensional-array

如何在 numpy 二维数组中存储列表?

import numpy  
A = numpy.empty([5,5], dtype=**?**)  
Run Code Online (Sandbox Code Playgroud)

这里变量列表类型的数据类型应该是什么?或者是否有不同的方法来实现这一点,我强烈认为是这种情况。

Bog*_*dan 6

我想你想要的是:

>>> input = numpy.array(range(10))
>>> data = numpy.zeros((2,2), dtype=numpy.ndarray)
>>> data[1][1] = input
>>> data
    array([[0, 0],
          [0, [0 1 2 3 4 5 6 7 8 9]]], dtype=object)
Run Code Online (Sandbox Code Playgroud)