SciPy

numpy.copyΒΆ

numpy.copy(a, order='K')[source]ΒΆ

Return an array copy of the given object.

Parameters:
a : array_like

Input data.

order : {β€˜C’, β€˜F’, β€˜A’, β€˜K’}, optional

Controls the memory layout of the copy. β€˜C’ means C-order, β€˜F’ means F-order, β€˜A’ means β€˜F’ if a is Fortran contiguous, β€˜C’ otherwise. β€˜K’ means match the layout of a as closely as possible. (Note that this function and ndarray.copy are very similar, but have different default values for their order= arguments.)

Returns:
arr : ndarray

Array interpretation of a.

Notes

This is equivalent to:

>>> np.array(a, copy=True)  #doctest: +SKIP

Examples

Create an array x, with a reference y and a copy z:

>>> x = np.array([1, 2, 3])
>>> y = x
>>> z = np.copy(x)

Note that, when we modify x, y changes, but not z:

>>> x[0] = 10
>>> x[0] == y[0]
True
>>> x[0] == z[0]
False

Previous topic

numpy.ascontiguousarray

Next topic

numpy.frombuffer