I have a 3D NumPy array (2700, 4000, 2) and I want to convert it two different 2D array. I mean, my new two arrays will be (2700,4000).
I am new at Python programming. Is there any way to do this?
IIUC, here you go.
Code
#Define the 3D array
n1 = np.ones((2700,4000,2))
#Get the first 2D array
n2 = n1[:,:,0]
#Get the second 2D array
n3 = n1[:,:,1]
print("Original Shape : ", n1.shape)
print("First array shape : ", n2.shape)
print("Second array shape : ", n3.shape)
Output
Original Shape : (2700, 4000, 2)
First array shape : (2700, 4000)
Second array shape : (2700, 4000)
(2700, 4000)
arrays. It might help if you explain why you'd prefer two 2D arrays.