-1

I have two numpy arrays that have the same shape(4,1,2). How can I combine them and get a new array of size(8,1,2) with minimum lines of python code? Not changing values just put them together with A on the top B at the bottom.

    A=numpy.array([[[1,1]],
                   [[2,2]],
                   [[3,3]],
                   [[4,4]]]);


   B=numpy.array([[[5,5]],
                   [[6,6]],
                   [[7,7]],
                   [[8,8]]]);
mengmengxyz
  • 819
  • 5
  • 10
  • 12
  • I googled this "how to combine two numpy arrays" and found this http://stackoverflow.com/questions/9236926/concatenating-two-one-dimensional-numpy-arrays I don't even know what numpy is and figured it out... lazy question – Adam Buchanan Smith Mar 11 '16 at 01:01

2 Answers2

1

numpy.concatenate() should do what you want:

numpy.concatenate((A, B))
pp_
  • 3,435
  • 4
  • 19
  • 27
0

Use numpy.vstack()

numpy.vstack([A,B])
xvan
  • 4,554
  • 1
  • 22
  • 37