![]() |
VOOZH | about |
Many times there is a need to copy one array to another. Numpy provides the facility to copy array using different methods. In this
There are various ways to copies created in NumPy arrays in Python, here we are discussing some generally used methods for copies created in NumPy arrays those are following.
np.copy() FunctionIn the below example, the given Numpy array 'org_array' is copied to another array 'copy_array' using np.copy () function.
Output:
Original array:
[ 1.54 2.99 3.42 4.87 6.94 8.21 7.65 10.5 77.5 ]
Copied array:
[ 1.54 2.99 3.42 4.87 6.94 8.21 7.65 10.5 77.5 ]
In this example, the given 2-D Numpy array 'org_array' is copied to another array 'copy_array' using np.copy () function.
Output:
Original array:
[[23 46 85]
[43 56 99]
[11 34 55]]
Copied array:
[[23 46 85]
[43 56 99]
[11 34 55]]
In the below example, the given Numpy array 'org_array' is copied to another array 'copy_array' using Assignment Operator.
Output:
Original Array:
[[99 22 33]
[44 77 13]]
Copied Array:
[[99 22 33]
[44 77 13]]