1. np.append
a = np.array([[1,2,3], [4,5,6]]) # shape: 2,3
print(a)
b = np.array([[7,8,9]]) # shape: 1,3
print(b)
c = np.array([[11], [12]]) # shape: 2,1
print(c)
merged = np.append(a, b, axis=0) # 按行合并 shape: 3,3
print(merged)
merged = np.append(a, c, axis=1) # 按列合并 shape: 2,4
print(merged)
2. np.concatenate
a = np.array([[1,2,3], [4,5,6]]) # shape: 2,3
print(a)
b = np.array([[7,8,9]]) # shape: 1,3
print(b)
c = np.array([[11], [12]]) # shape: 2,1
print(c)
merged = np.concatenate((a, b), axis=0) # 按行合并 shape: 3,3
print(merged)
merged = np.concatenate((a, c), axis=1) # 按列合并 shape: 2,4
print(merged)