How to copy numpy arrays into another array using numpy.copy() function
In this article, you will learn how to copy numpy arrays into another array using numpy.copy() function
Syntax: numpy.copy(a, order=’K’)
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.
import numpy as np
a = np.array([1, 2, 3, 4])
b = np.copy(a)
print(b)
Output:
[1 2 3 4]