VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-ndarray-copy/

⇱ NumPy ndarray.copy() Method | Make Copy of a Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

NumPy ndarray.copy() Method | Make Copy of a Array

Last Updated : 11 Jul, 2025

The ndarray.copy() method returns a copy of the array.

It is used to create a new array that is a copy of an existing array but does not share memory with it. This means that making any changes to the original array won't affect the existing array.

Example

Output

x is: 
[[0 1 2 3]
[4 5 6 7]]
y is :
[[0 1 2 3]
[4 5 6 7]]
x is copied to y

Syntax

 Syntax: numpy.ndarray.copy(order='C') 

Parameters:

  • Order : 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

Returns: Copy of an Array

How to make a copy of a NumPy array

To make a copy of a NumPy array in Python, we use ndarray.copy method of the NumPy library

Let us understand it better with an example:

Example: Make a Copy of ndarray


Output
x is:
 [[0 1]
 [2 3]]

 Now x is : 
 [[1 1]
 [1 1]]

 y is: 
 [[0 1]
 [2 3]]
Comment
Article Tags: