Let’s check how to copy an array with Numpy. We will use the Numpy copy method for that purpose.
Copying an array
To create a copy of an array, you just need to use the Numpy copy function. Put your array as an argument to the copy function.
import numpy as np my_array = np.array([1, 3, 5]) print(f"This is my array: \n{my_array}") array_copy = np.copy(my_array) print(f"This is copy of my array: \n{array_copy}")
This is how you create a copy. Alternatively, you can assign an array to another (array_copy = my_array) or create a view of an array.