Copy in NumPy:
The contents which are physically stored in another location, it is known as Copy. It usually returns the copy of original array which is stored at the new location. This copy doesn't share any memory with original array.
The changes made to copy will not effect original array. Thus, any changes made to the original array will not affect the copy.
import numpy as np a=np.array([10,20,30,40,50]) #original array b=a.copy() #copying the array a=100 #changing the original array print(a) print(b)
[100 20 30 40 50] [10 20 30 40 50]
Therefore, changes made in copy are not reflected in the original array.
View in NumPy:
In this the view does not own any data.The changes made to this view will also affect the original array and if any changes made to the original array will affect the view.
This function returns a view of the original array stored at the existing location.It doesn't have its own data or memory instead it uses original array.
import numpy as np a=np.array([10,20,30,40,50])#Original Array b = a.view() a = 70 #changing the original array print(a) print(b)
[70 20 30 40 50] [70 20 30 40 50]