Copies and Views
Slices are views that share memory. copy makes independent data.
Example
a = np.arange(5)
v = a[1:4]
v[0] = 99
print(a)
c = a[1:4].copy()
c[0] = 0
print(a)Result
[ 0 99 2 3 4] [ 0 99 2 3 4]
Exercise
Independent data.
a.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.