I am trying to copy an array into another.
a = np.array([1]*3)
b = np.array([2]*2)
I tried copyto()
np.copyto(a,b)
But I get:
Traceback (most recent call last): File "", line 1, in np.copyto(a,b) ValueError: could not broadcast input array from shape (2) into shape (3)
How can I get a
to become equal to [2,2,1] ?
The Array. Copy() method in C# is used to copy section of one array to another array. Array. Copy(src, dest, length);
JavaScript Arrays Copy part of an ArrayThe slice() method returns a copy of a portion of an array.
Assign the values in b
to a slice of a
:
In [16]: a[:len(b)] = b
In [17]: a
Out[17]: array([2, 2, 1])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With