numpy.copy

numpy.copy(a)

Return an array copy of the given object.

Parameters:

a : array_like

Input data.

Returns:

arr : ndarray

Array interpretation of a.

Notes

This is equivalent to

>>> np.array(a, copy=True)

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.asmatrix

Next topic

numpy.frombuffer

This Page