Python Forum
Adding data in 3D array from 2D numpy array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding data in 3D array from 2D numpy array
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to fill datetime64 field in numpy structured array? AlekseyPython 0 75 Oct-20-2020, 08:17 AM
Last Post: AlekseyPython
  using silhouette score for each sample of an array with each cluster alex80 1 448 Sep-25-2020, 11:35 PM
Last Post: scidam
  Calculating consecutive days in a 3D array chai0404 0 384 Aug-27-2020, 10:28 PM
Last Post: chai0404
  Array issues Bmart6969 1 295 Jul-18-2020, 11:03 AM
Last Post: ndc85430
  cannot reshape array of size 0 into shape Roro 2 1,094 Jun-14-2020, 11:28 AM
Last Post: Roro
  Python changed array shape without telling me BrendanGolledge 3 363 Jun-11-2020, 07:41 AM
Last Post: Yoriz
  array coding problem pberrett 3 425 May-08-2020, 05:54 AM
Last Post: nnk
  ValueError: Found array with 0 samples marcellam 1 637 Apr-22-2020, 04:12 PM
Last Post: jefsummers
  np.array question hissonrr 3 456 Apr-20-2020, 01:15 PM
Last Post: hissonrr
  Create multiple quiver plots 3D array PengEng 0 320 Apr-14-2020, 12:57 PM
Last Post: PengEng

Forum Jump:

User Panel Messages

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