import numpy as np
a = np.array([[0, 1, 2],
[0, 1, 2],
[1, 1, 2]])
a[[0, 1]] = 100 # Changed
print(a)
a[[0, 1]][0, 0] = 98 # Not Changed
print(a)
a[0:2][0, 0] = 99 # Changed
print(a)
the output is :
# first
[[100 100 100]
[100 100 100]
[ 1 1 2]]
# second
[[100 100 100]
[100 100 100]
[ 1 1 2]]
# third
[[ 99 100 100]
[100 100 100]
[ 1 1 2]]
so why the second way didn't change the a array, and the first way and third way worked? I had googled many answers,but I still not understand.