Create a view of the array, modify the original array, and then display both arrays.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) x = arr.view() arr[0] = 42 print(arr) print(x) |
The view should be impacted by any changes made to the original array. |
Create a view of the array, modify the view, and then display both arrays.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) x = arr.view() x[0] = 31 print(arr) print(x) |