Numpy将二维数组添加到空数组

使用append函数将一个二维数组添加到一个空数组,关键是维度要对的上

a=np.empty([0,3])
b = np.array([[1,2,3],[4,5,6]])
c=[[7,8,9]]

print(a.shape)
print(b.shape)


a = np.append(a, b, axis=0)

a = np.append(a, c, axis=0)

print(a.shape)
print(b.shape)

猜你喜欢

转载自blog.csdn.net/u013701860/article/details/81416284
今日推荐