Python Forum
Adding data in 3D array from 2D numpy array - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Adding data in 3D array from 2D numpy array (/thread-28543.html)



Adding data in 3D array from 2D numpy array - asmasattar - Jul-23-2020

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)