通过阅读 Python 文档和 stackoverflow,我无法弄清楚。可能我想错了方向..
假设我有一个预定义的 2D Numpy 数组,如下所示:
a = np.zeros(shape=(3,2))
print a
array([[ 0., 0.],
[ 0., 0.],
[ 0., 0.]])
现在我想用一维数据数组(一个接一个)填充这个二维数组的每一列,如下所示:
b = np.array([1,2,3])
# Some code, that I just can't figure out. I've studied insert, column_stack,
# h_stack, append. Nothing seems to do what I need
print a
array([[ 1., 0.],
[ 2., 0.],
[ 3., 0.]])
c = np.array([4,5,6])
# Some code, that I just can't figure out. I've studied insert, column_stack,
# h_stack, append. Nothing seems to do what I need
print a
array([[ 1., 4.],
[ 2., 5.],
[ 3., 6.]])
任何建议,将不胜感激!