>>> a = np.arange(12).reshape(3,4)
>>> a[0:3:2, :][:, [0,2]] = 100 ### the first time
>>> a
array([[100, 1, 100, 3],
[ 4, 5, 6, 7],
[100, 9, 100, 11]])
>>> a[:, [0, 2]][0:3:2, :] = 0 ### second time
>>> a
array([[100, 1, 100, 3],
[ 4, 5, 6, 7],
[100, 9, 100, 11]])
I am really confused about views and copies in python. The code above shows that the first time the given rows and columns in array a was changed to 100, which changed the original array a.
However, the second time the original array was not changed. Why is that?