numpy
的concatenate
函数用于连接两个数组:
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
c = np.concatenate((a, b), axis=0)
print("c =", c)
d = np.concatenate((a, b), axis=None)
print("d =", d)
执行结果:
c = [[1 2]
[3 4]
[5 6]]
d = [1 2 3 4 5 6]