1

Suppose I have a three dimensional array, which I'll call A, where the first dimensional is equal to N. How do I find B, which is equivalent to:

np.concatenate((A[0],A[1],A[2],...,A[N-1]),axis=1)

As an example, suppose I have:

A = np.array([[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]],[[17,18,19,20],[21,22,23,24]]])

print(A)
[[[ 1  2  3  4]
  [ 5  6  7  8]]

 [[ 9 10 11 12]
  [13 14 15 16]]

 [[17 18 19 20]
  [21 22 23 24]]]

How do I (in a single line) return B, which will be equal to:

print(B)
[[ 1  2  3  4  9 10 11 12 17 18 19 20]
 [ 5  6  7  8 13 14 15 16 21 22 23 24]]

I've tried reshaping, but this doesn't return the required order of the elements. Thanks.

Mathew Carroll
  • 357
  • 3
  • 14

0 Answers0