Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Concatenate 3D arrays
#2
Ok I fixed it and I figured out my mistake: axis=0 becomes the depth one for a 3D array and not rows axis as in a 2D array Tongue

A = np.zeros( (2, 3, 5) )
print("A = {}\n".format(A))
## 1rst term => depth
## 2 other terms => (i,j)

## basic 2D array
B = np.ones( (3, 5) )
print("B = {}\n".format(B))

## 2D array reshaped into 3D one prior to be concatenated
Bprime = B.reshape(1,3,5)
print("Bprime = {}\n".format(Bprime))

## C is created and suppoed to be A expanded by B
# C = np.concatenate( (A, Bprime) )
C = np.concatenate( (A, Bprime), axis = 0)
print("C = {}\n".format(C))
Reply


Messages In This Thread
Concatenate 3D arrays - by paul18fr - Apr-09-2021, 02:24 PM
RE: Concatenate 3D arrays - by paul18fr - Apr-09-2021, 02:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  comparing floating point arrays to arrays of integers in Numpy amjass12 0 1,632 Jul-26-2021, 11:58 AM
Last Post: amjass12
  Numpy arrays and compatability with Fortran arrays merrittr 0 1,883 Sep-03-2019, 03:54 AM
Last Post: merrittr
  concatenate mcgrim 1 2,240 Mar-22-2019, 01:31 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020