How to copy subset of a array in Ipython



I am currently trying to copy the subset of a array but when ever I am performing any operation on it also changes the original array but I want that the original should not change.

In [51]: arr = np.arange(10)
In [52]: arr_slice = arr[5:8]
In [53]: arr_slice[1] = 12345
In [54]: arr
Out[54]: array([ 0, 1, 2, 3, 4, 12, 12345, 12, 8, 9])


It is a property of numpy library that whenever we perform any slicing operation onto it always effects the original array.
So you can use the copy function for copying a part of an array and then perform any operation onto it.


Now, you can perform any mathematical operation on to x.

Hope this helps!