bundles / numpy 2.4.4 / numpy / ma / MaskedArray
class
numpy.ma:MaskedArray
source: /numpy/ma/__init__.py
Signature
class MaskedArray ( data = None , mask = False , dtype = None , copy = False , subok = True , ndmin = 0 , fill_value = None , keep_mask = True , hard_mask = None , shrink = True , order = None ) Summary
An array class with possibly masked values.
Extended Summary
Masked values of True exclude the corresponding element from any computation.
Construction
x = MaskedArray(data, mask=nomask, dtype=None, copy=False, subok=True, ndmin=0, fill_value=None, keep_mask=True, hard_mask=None, shrink=True, order=None)
Parameters
data: array_likeInput data.
mask: sequence, optionalMask. Must be convertible to an array of booleans with the same shape as
data. True indicates a masked (i.e. invalid) data.dtype: dtype, optionalData type of the output. If
dtypeis None, the type of the data argument (data.dtype) is used. Ifdtypeis not None and different fromdata.dtype, a copy is performed.copy: bool, optionalWhether to copy the input data (True), or to use a reference instead. Default is False.
subok: bool, optionalWhether to return a subclass of MaskedArray if possible (True) or a plain MaskedArray. Default is True.
ndmin: int, optionalMinimum number of dimensions. Default is 0.
fill_value: scalar, optionalValue used to fill in the masked values when necessary. If None, a default based on the data-type is used.
keep_mask: bool, optionalWhether to combine
maskwith the mask of the input data, if any (True), or to use onlymaskfor the output (False). Default is True.hard_mask: bool, optionalWhether to use a hard mask or not. With a hard mask, masked values cannot be unmasked. Default is False.
shrink: bool, optionalWhether to force compression of an empty mask. Default is True.
order: {'C', 'F', 'A'}, optionalSpecify the order of the array. If order is 'C', then the array will be in C-contiguous order (last-index varies the fastest). If order is 'F', then the returned array will be in Fortran-contiguous order (first-index varies the fastest). If order is 'A' (default), then the returned array may be in any order (either C-, Fortran-contiguous, or even discontiguous), unless a copy is required, in which case it will be C-contiguous.
Examples
import numpy as np
✓data = np.arange(6).reshape((2, 3)) np.ma.MaskedArray(data, mask=[[False, True, False], [False, False, True]])✓
np.ma.MaskedArray(data, mask=False)
✓np.ma.MaskedArray(data, mask=True)
✓np.False_ is np.ma.nomask
✓Aliases
-
numpy.ma.MaskedArray