有没有办法在数组上执行滚动,但是不是只拥有只有不同可视化数据的数据副本?
示例可能会澄清:给定b
a
...
>>> a = np.random.randint(0, 10, (3, 3))
>>> a
array([[6, 7, 4],
[5, 4, 8],
[1, 3, 4]])
>>> b = np.roll(a, 1, axis=0)
>>> b
array([[1, 3, 4],
[6, 7, 4],
[5, 4, 8]])
...如果我在数组b
上执行作业......
>>> b[2,2] = 99
>>> b
array([[ 1, 3, 4],
[ 6, 7, 4],
[ 5, 4, 99]])
...... a
的内容不会改变......
>>> a
array([[6, 7, 4],
[5, 4, 8],
[1, 3, 4]])
...相反,我想:
>>> a
array([[6, 7, 4],
[5, 4, 99], # observe as `8` has been changed here too!
[1, 3, 4]])
提前感谢您的时间和专业知识!