The ma.masked_all_like()
function in Python empties a masked array with the properties of an existing array.
ma.masked_all_like(arr)
The ma.masked_all_like()
function takes the parameter value arr
, which represents an input array with the same shape and data type as the required MaskedArray.
The ma.masked_all_like()
function returns a masked array where all the data are masked.
import numpy as npimport numpy.ma as ma# creating an arraymyarray = np.array([[1,2,3], [4,5,6]])# implementing the ma.masked_all_like() functionnewarray = ma.masked_all_like(myarray)# printing the old arrayprint(myarray)# printing the masked arrayprint(newarray)
myarray
, using the array()
function.ma.masked_all_like()
function on the input array. The result is assigned to a variable, newarray
.myarray
.newarray
.