Masked array operations#

Constants#

ma.MaskType

alias of bool

Creation#

From existing data#

ma.masked_array

alias of MaskedArray

ma.array(data[, dtype, copy, order, mask, ...])

An array class with possibly masked values.

ma.copy(self, *args, **params) a.copy(order=)

Return a copy of the array.

ma.frombuffer(buffer[, dtype, count, ...])

Interpret a buffer as a 1-dimensional array.

ma.fromfunction(function, shape, **dtype)

Construct an array by executing a function over each coordinate.

ma.MaskedArray.copy([order])

Return a copy of the array.

ma.diagflat

Create a two-dimensional array with the flattened input as a diagonal.

Ones and zeros#

ma.empty(shape[, dtype, order, device, like])

Return a new array of given shape and type, without initializing entries.

ma.empty_like(prototype[, dtype, order, ...])

Return a new array with the same shape and type as a given array.

ma.masked_all(shape[, dtype])

Empty masked array with all elements masked.

ma.masked_all_like(arr)

Empty masked array with the properties of an existing array.

ma.ones(shape[, dtype, order])

Return a new array of given shape and type, filled with ones.

ma.ones_like

Return an array of ones with the same shape and type as a given array.

ma.zeros(shape[, dtype, order, like])

Return a new array of given shape and type, filled with zeros.

ma.zeros_like

Return an array of zeros with the same shape and type as a given array.


Inspecting the array#

ma.all(self[, axis, out, keepdims])

Returns True if all elements evaluate to True.

ma.any(self[, axis, out, keepdims])

Returns True if any of the elements of a evaluate to True.

ma.count(self[, axis, keepdims])

Count the non-masked elements of the array along the given axis.

ma.count_masked(arr[, axis])

Count the number of masked elements along the given axis.

ma.getmask(a)

Return the mask of a masked array, or nomask.

ma.getmaskarray(arr)

Return the mask of a masked array, or full boolean array of False.

ma.getdata(a[, subok])

Return the data of a masked array as an ndarray.

ma.nonzero(self)

Return the indices of unmasked elements that are not zero.

ma.shape(obj)

Return the shape of an array.

ma.size(obj[, axis])

Return the number of elements along a given axis.

ma.is_masked(x)

Determine whether input has masked values.

ma.is_mask(m)

Return True if m is a valid, standard mask.

ma.isMaskedArray(x)

Test whether input is an instance of MaskedArray.

ma.isMA(x)

Test whether input is an instance of MaskedArray.

ma.isarray(x)

Test whether input is an instance of MaskedArray.

ma.isin(element, test_elements[, ...])

Calculates element in test_elements, broadcasting over element only.

ma.in1d(ar1, ar2[, assume_unique, invert])

Test whether each element of an array is also present in a second array.

ma.unique(ar1[, return_index, return_inverse])

Finds the unique elements of an array.

ma.MaskedArray.all([axis, out, keepdims])

Returns True if all elements evaluate to True.

ma.MaskedArray.any([axis, out, keepdims])

Returns True if any of the elements of a evaluate to True.

ma.MaskedArray.count([axis, keepdims])

Count the non-masked elements of the array along the given axis.

ma.MaskedArray.nonzero()

Return the indices of unmasked elements that are not zero.

ma.shape(obj)

Return the shape of an array.

ma.size(obj[, axis])

Return the number of elements along a given axis.

ma.MaskedArray.data

Returns the underlying data, as a view of the masked array.

ma.MaskedArray.mask

Current mask.

ma.MaskedArray.recordmask

Get or set the mask of the array if it has no named fields.


Manipulating a MaskedArray#

Changing the shape#

ma.ravel(self[, order])

Returns a 1D version of self, as a view.

ma.reshape(a, new_shape[, order])

Returns an array containing the same data with a new shape.

ma.resize(x, new_shape)

Return a new masked array with the specified size and shape.

ma.MaskedArray.flatten([order])

Return a copy of the array collapsed into one dimension.