Numpy asarray将list()包裹在列表周围

时间:2019-04-05 16:05:22

标签: python list numpy

我在尝试转换为numpy数组的列表中有列表,但是它将list()包裹在每个元素周围。

这意味着在尝试对其进行切片时,出现诸如“ IndexError:数组的索引过多”之类的错误。

list = f()
print(list)
np_array = np.asarray(list)
print(np_array)

输出:

[[0,5,2,5,5,4,5],[1,0,5,2,2,3,4],[2,5,3,4,8,5,2]]

list([0,5,2,5,5,4,5])
list([1,0,5,2,2,3,4])
list([2,5,3,4,8,5,2])

我希望结果看起来像

[[0,5,2,5,5,4,5],[1,0,5,2,2,3,4],[2,5,3,4,8,5,2]]

[0,5,2,5,5,4,5]
[1,0,5,2,2,3,4]
[2,5,3,4,8,5,2]

0 个答案:

没有答案