减少并追加Numpy

时间:2019-07-03 19:47:46

标签: python numpy append reduce

有没有一种方法可以在Numpy的append中使用reduce?我想像这样将3个数组附加在一起:

a = np.array([1,2,3])  
b = np.array([11,12,13])  
c = np.array([21,22,23])
#below is my real code - the above is just for this example)
np.append.reduce((a,b,c))

,但是reduce似乎没有通过append实现。感谢您的任何建议。

输出应为:

array([ 1,  2,  3, 11, 12, 13, 21, 22, 23])

1 个答案:

答案 0 :(得分:0)

np.r_ []会干净地执行此操作...

a = np.array([1,2,3])  
b = np.array([11,12,13])  
c = np.array([21,22,23])
#below is my real code - the above is just for this example)
np.r_[a,b,c]