Issue
Extremely new and pretty confused using python.
I have two arrays. Array 1 is 2x2 and array 2 is 2x3. I'm trying to multiply the two arrays to create array 3, and the 3rd column in array 3 is to repeat the 2 numbers in the 3rd column from array 2. I'm not sure if there's a specific way to do that, so I was thinking I'd slice array 2 to make it 2x2, multiply array1 with array2slice. This would give me a 2x2 array with the multiplied values. All I would need to do is add on the removed 3rd column (eg 1 and 5). I was thinking to do that with np.append but that doesn't seem to work (I'm sure to be doing it wrong).
Any help would be appreciated.
array2Slice = np.array(array2[0:2, 0:2])
WIParray3 = np.multiply(array1,array2Slice)
array3 = np.append(WIParray3, [1],[5],axis = 1)
Solution
I think this might be a syntax error. Looking at https://numpy.org/doc/stable/reference/generated/numpy.append.html i would suggest:
array3 = np.append(WIParray3, [[1],[5]],axis = 1)
Also providing an error message might help solve your problem :)
Answered By - KaaraT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.