Mar-30-2020, 07:33 PM
(This post was last modified: Apr-01-2020, 12:22 AM by ThemePark. Edited 1 time in total.)

Suppose I have the following code:

import numpy as np a=np.zeros((2),dtype=np.object) b=np.array([[11],[13]]) a[0]=b[0] a[1]=b[1] print(a)This gives me the wanted result of "[array([11]) array([13])]". But if I have a big array, it's too tedious to add a line for each index. So I wanna do it in some way like this:

a[0:2]=b[0:2]But that gives me the error "ValueError: could not broadcast input array from shape (2,1) into shape (2)". So how do I have to write that one line to accomplish the same as the code at the beginning?