Python Forum

Full Version: Adding data in 3D array from 2D numpy array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have one array of size Arr1= 2096 x 49, another array Arr2 of size 121 x 1232 x 49. and list of u_nodes[] have size 2096 and v_nodes of size 2096 containing the row and column indexes. I want to get row and column from these lists and values from Arr1 and insert in 3D array.
Arr2 = np.full((121, 1232, 49), -1, dtype=np.int32) //initializing
Arr2[u_nodes, v_nodes] = np.array([ Arr2[i] for i in range(2096)]) 
but its not working. Following error
Error:
ValueError: shape mismatch: value array of shape (2096,1,49) could not be broadcast to indexing result of shape (2296,49)