What is the numpy.ma.copy() method in Python?

Overview

In Python, the ma.copy() method is used to return a copy of an input array.

Syntax

ma.copy(self, *args, **params) a.copy(order='C') = <numpy.ma.core._frommethod object>
Syntax for the ma.copy() method

Parameter value

This method takes a parameter value, order, which represents the memory layout of the copy. It can take any of the following order values: "C", "F", "A", and "K" orders.

Return value

This method returns a copy of the array.

Code example

import numpy as np
# creating an input array
myarray = np.array([[1,2,3], [4,5,6]])
# copying the array
newarray = myarray.copy(order="F")
# printing the copied array
print(newarray)
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources