Remember that in python, if you have an array A and say "B=A", this does NOT copy the array A into a new array B. Rather, B just points to the data in A. So now if you say B[5]=42, then afterwards also A[5]==42 ! The way around this is to say B=np.copy(A).
I hope this helps!