如何拼接numpy数组?
我想要连接所有的numpy数组。
例如,有一些numpy数组如下所示
a = numpy.array([1,2,3])
b = numpy.array([4,5,6])
c = numpy.array([7,8,9])将它们连接在一起。
我们需要一个额外的空变量。
tot = numpy.concatenate(tot, a)
tot = numpy.concatenate(tot, b)
tot = numpy.concatenate(tot, c)如何声明tot为空变量?(如果有太多的数组?)
发布于 2020-09-20 01:28:45
您需要将它们放在元组中:
>>> tot = numpy.concatenate((a,b,c))
>>> tot
array([1, 2, 3, 4, 5, 6, 7, 8, 9])发布于 2020-09-20 01:30:50
没有回答你的问题,但出于好奇心,我想提一下。
a = numpy.array([1,2,3])
b = numpy.array([4,5,6])
c = numpy.array([7,8,9])
d = numpy.array(list(a)+list(b)+list(c))发布于 2020-09-20 01:36:13
tot = np.concatenate([a,b,c], axis=0)https://stackoverflow.com/questions/63971521
复制相似问题