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
  [Numpy] How to store different data type in one numpy array? water 7 297 Mar-26-2024, 02:18 PM
Last Post: snippsat
  boolean array: looking for all rows where all is True paul18fr 4 1,175 Jan-04-2023, 09:58 PM
Last Post: paul18fr
  reshaping 2D numpy array paul18fr 3 971 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Turn list of arrays into an array of lists Cola_Reb 6 1,661 Jul-20-2022, 06:55 PM
Last Post: Cola_Reb
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,530 Jul-19-2022, 06:31 AM
Last Post: paul18fr
Question how to write a function that accepts a 1D array as a parameter in Python SuperNinja3I3 1 1,552 Jul-02-2022, 01:55 PM
Last Post: Larz60+
  replace sets of values in an array without using loops paul18fr 7 1,630 Jun-20-2022, 08:15 PM
Last Post: paul18fr
  how to parse this array with pandas? netanelst 1 1,299 May-17-2022, 12:42 PM
Last Post: netanelst
  semantics of comma inside array brackets usercat123 2 1,324 Apr-23-2022, 09:08 AM
Last Post: usercat123
  numpy adding columns rwahdan 4 2,284 Sep-21-2021, 08:25 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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