-
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 ofa
as closely as possible. (Note that this function and :meth: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
1>>> np.array(a, copy
=
True
)
Examples
Create an array x, with a reference y and a copy z:
123>>> x
=
np.array([
1
,
2
,
3
])
>>> y
=
x
>>> z
=
np.copy(x)
Note that, when we modify x, y changes, but not z:
12345>>> x[
0
]
=
10
>>> x[
0
]
=
=
y[
0
]
True
>>> x[
0
]
=
=
z[
0
]
False
numpy.copy()

2025-01-10 15:47:30
Please login to continue.