The numpy.copy()
function in Python is used to return a copy of an array of the given object.
numpy.copy(a, order='K', subok=False)
The numpy.copy()
function takes the following parameters:
a
: This represents the input data.order
: This represents the memory layout of the copy. This is optional.subok
: Subclasses will be passed through if True
. Otherwise, the returned array will be forced to be a base-class array. This is optional.The numpy.copy()
function returns a copy of the content of the input data.
import numpy as np# creating an arraythisarray = np.array([1, 2, 3, 4, 5])# implementing the numpy.copy() functionmyarray = np.copy(thisarray)print(myarray)
numpy
module.thisarray
with 5
elements using the numpy.array()
function.thisarray
array and assign it to another array myarray
.myarray
.