Xav*_*ino 5 python arrays numpy
我正在尝试将 Numpy 数组的一个元素设置为另一个 Numpy 数组。我不确定如何做到这一点,因为每次我尝试都会得到ValueError: setting an array element with a sequence.
我知道这对 Python 来说是可能的,list因为我可以将新数组附加到列表中并且它会起作用。
这是我正在尝试做的一个例子:
import numpy as np
finalArray = np.zeros(3)
finalList = []
a = np.arange(128).reshape(32,4)
b = np.arange(124).reshape(31,4)
c = np.arange(120).reshape(30,4)
# This works
finalList.append(a)
finalList.append(b)
finalList.append(c)
# This doesn't work
finalArray[0] = a
finalArray[1] = b
finalArray[2] = c
Run Code Online (Sandbox Code Playgroud)
关于如何做到这一点的任何想法?
| 归档时间: |
|
| 查看次数: |
5241 次 |
| 最近记录: |