Constants¶

 ma.MaskType Numpy’s Boolean type. Character code: ?. Alias: bool8

Creation¶

From existing data¶

 ma.masked_array An array class with possibly masked values. ma.array(data[, dtype, copy, order, mask, ...]) An array class with possibly masked values. ma.copy copy ma.frombuffer(buffer[, dtype, count, offset]) Interpret a buffer as a 1-dimensional array. ma.fromfunction(function, shape, **kwargs) Construct an array by executing a function over each coordinate. ma.MaskedArray.copy([order]) Return a copy of the array.

Ones and zeros¶

 ma.empty(shape[, dtype, order]) Return a new array of given shape and type, without initializing entries. ma.empty_like(a) 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.zeros(shape[, dtype, order]) Return a new array of given shape and type, filled with zeros.

Inspecting the array¶

Changing the shape¶

 ma.ravel(self) 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. ma.MaskedArray.ravel() Returns a 1D version of self, as a view. ma.MaskedArray.reshape(*s, **kwargs) Give a new shape to the array without changing its data. ma.MaskedArray.resize(newshape[, refcheck, ...])

Modifying axes¶

 ma.swapaxes swapaxes ma.transpose(a[, axes]) Permute the dimensions of an array. ma.MaskedArray.swapaxes(axis1, axis2) Return a view of the array with axis1 and axis2 interchanged. ma.MaskedArray.transpose(*axes) Returns a view of the array with axes transposed.

Changing the number of dimensions¶

 ma.atleast_1d(*arys) Convert inputs to arrays with at least one dimension. ma.atleast_2d(*arys) View inputs as arrays with at least two dimensions. ma.atleast_3d(*arys) View inputs as arrays with at least three dimensions. ma.expand_dims(x, axis) Expand the shape of an array. ma.squeeze(a) Remove single-dimensional entries from the shape of an array. ma.MaskedArray.squeeze() Remove single-dimensional entries from the shape of a. ma.column_stack(tup) Stack 1-D arrays as columns into a 2-D array. ma.concatenate(arrays[, axis]) Concatenate a sequence of arrays along the given axis. ma.dstack(tup) Stack arrays in sequence depth wise (along third axis). ma.hstack(tup) Stack arrays in sequence horizontally (column wise). ma.hsplit(ary, indices_or_sections) Split an array into multiple sub-arrays horizontally (column-wise). ma.mr_ Translate slice objects to concatenation along the first axis. ma.row_stack(tup) Stack arrays in sequence vertically (row wise). ma.vstack(tup) Stack arrays in sequence vertically (row wise).

Joining arrays¶

 ma.column_stack(tup) Stack 1-D arrays as columns into a 2-D array. ma.concatenate(arrays[, axis]) Concatenate a sequence of arrays along the given axis. ma.dstack(tup) Stack arrays in sequence depth wise (along third axis). ma.hstack(tup) Stack arrays in sequence horizontally (column wise). ma.vstack(tup) Stack arrays in sequence vertically (row wise).

 ma.make_mask(m[, copy, shrink, flag, dtype]) Create a boolean mask from an array. ma.make_mask_none(newshape[, dtype]) Return a boolean mask of the given shape, filled with False. ma.mask_or(m1, m2[, copy, shrink]) Combine two masks with the logical_or operator. ma.make_mask_descr(ndtype) Construct a dtype description list from a given dtype.

Conversion operations¶

> to a ndarray¶

 ma.compress_cols(a) Suppress whole columns of a 2-D array that contain masked values. ma.compress_rowcols(x[, axis]) Suppress the rows and/or columns of a 2-D array that contain ma.compress_rows(a) Suppress whole rows of a 2-D array that contain masked values. ma.compressed(x) Return all the non-masked data as a 1-D array. ma.filled(a[, fill_value]) Return input as an array with masked data replaced by a fill value. ma.MaskedArray.compressed() Return all the non-masked data as a 1-D array. ma.MaskedArray.filled([fill_value]) Return a copy of self, with masked values filled with a given value.

> to another object¶

 ma.MaskedArray.tofile(fid[, sep, format]) Save a masked array to a file in binary format. ma.MaskedArray.tolist([fill_value]) Return the data portion of the masked array as a hierarchical Python list. ma.MaskedArray.torecords() Transforms a masked array into a flexible-type array. ma.MaskedArray.tostring([fill_value, order]) Return the array data as a string containing the raw bytes in the array.

Pickling and unpickling¶

 ma.dump(a, F) Pickle a masked array to a file. ma.dumps(a) Return a string corresponding to the pickling of a masked array. ma.load(F) Wrapper around cPickle.load which accepts either a file-like object ma.loads(strg) Load a pickle from the current string.

 ma.common_fill_value(a, b) Return the common filling value of two masked arrays, if any. ma.default_fill_value(obj) Return the default fill value for the argument object. ma.maximum_fill_value(obj) Return the minimum value that can be represented by the dtype of an object. ma.maximum_fill_value(obj) Return the minimum value that can be represented by the dtype of an object. ma.set_fill_value(a, fill_value) Set the filling value of a, if a is a masked array. ma.MaskedArray.get_fill_value() Return the filling value of the masked array. ma.MaskedArray.set_fill_value([value]) Set the filling value of the masked array. ma.MaskedArray.fill_value Filling value.

Arithmetics¶

 ma.anom(self[, axis, dtype]) Compute the anomalies (deviations from the arithmetic mean) along the given axis. ma.anomalies(self[, axis, dtype]) Compute the anomalies (deviations from the arithmetic mean) along the given axis. ma.average(a[, axis, weights, returned]) Return the weighted average of array over the given axis. ma.conjugate() Return the complex conjugate, element-wise. ma.corrcoef(x[, y, rowvar, bias, ...]) Return correlation coefficients of the input array. ma.cov(x[, y, rowvar, bias, allow_masked, ddof]) Estimate the covariance matrix. ma.cumsum(self[, axis, dtype, out]) Return the cumulative sum of the elements along the given axis. ma.cumprod(self[, axis, dtype, out]) Return the cumulative product of the elements along the given axis. ma.mean(self[, axis, dtype, out]) Returns the average of the array elements. ma.median(a[, axis, out, overwrite_input]) Compute the median along the specified axis. ma.power(a, b[, third]) Returns element-wise base array raised to power from second array. ma.prod(self[, axis, dtype, out]) Return the product of the array elements over the given axis. ma.std(self[, axis, dtype, out, ddof]) Compute the standard deviation along the specified axis. ma.sum(self[, axis, dtype, out]) Return the sum of the array elements over the given axis. ma.var(self[, axis, dtype, out, ddof]) Compute the variance along the specified axis. ma.MaskedArray.anom([axis, dtype]) Compute the anomalies (deviations from the arithmetic mean) along the given axis. ma.MaskedArray.cumprod([axis, dtype, out]) Return the cumulative product of the elements along the given axis. ma.MaskedArray.cumsum([axis, dtype, out]) Return the cumulative sum of the elements along the given axis. ma.MaskedArray.mean([axis, dtype, out]) Returns the average of the array elements. ma.MaskedArray.prod([axis, dtype, out]) Return the product of the array elements over the given axis. ma.MaskedArray.std([axis, dtype, out, ddof]) Compute the standard deviation along the specified axis. ma.MaskedArray.sum([axis, dtype, out]) Return the sum of the array elements over the given axis. ma.MaskedArray.var([axis, dtype, out, ddof]) Compute the variance along the specified axis.

Minimum/maximum¶

 ma.argmax(a[, axis, fill_value]) Function version of the eponymous method. ma.argmin(a[, axis, fill_value]) Returns array of indices of the maximum values along the given axis. ma.max(obj[, axis, out, fill_value]) Return the maximum along a given axis. ma.min(obj[, axis, out, fill_value]) Return the minimum along a given axis. ma.ptp(obj[, axis, out, fill_value]) Return (maximum - minimum) along the the given dimension (i.e. ma.MaskedArray.argmax([axis, fill_value, out]) Returns array of indices of the maximum values along the given axis. ma.MaskedArray.argmin([axis, fill_value, out]) Return array of indices to the minimum values along the given axis. ma.MaskedArray.max([axis, out, fill_value]) Return the maximum along a given axis. ma.MaskedArray.min([axis, out, fill_value]) Return the minimum along a given axis. ma.MaskedArray.ptp([axis, out, fill_value]) Return (maximum - minimum) along the the given dimension (i.e.

Sorting¶

 ma.argsort(a[, axis, kind, order, fill_value]) Return an ndarray of indices that sort the array along the specified axis. ma.sort(a[, axis, kind, order, endwith, ...]) Sort the array, in-place ma.MaskedArray.argsort([axis, kind, order, ...]) Return an ndarray of indices that sort the array along the specified axis. ma.MaskedArray.sort([axis, kind, order, ...]) Sort the array, in-place

Algebra¶

 ma.diag(v[, k]) Extract a diagonal or construct a diagonal array. ma.dot(a, b[, strict]) Return the dot product of two arrays. ma.identity(n[, dtype]) Return the identity array. ma.inner(a, b) Inner product of two arrays. ma.innerproduct(a, b) Inner product of two arrays. ma.outer(a, b) Compute the outer product of two vectors. ma.outerproduct(a, b) Compute the outer product of two vectors. ma.trace(self[, offset, axis1, axis2, ...]) Return the sum along diagonals of the array. ma.transpose(a[, axes]) Permute the dimensions of an array. ma.MaskedArray.trace([offset, axis1, axis2, ...]) Return the sum along diagonals of the array. ma.MaskedArray.transpose(*axes) Returns a view of the array with axes transposed.

Polynomial fit¶

 ma.vander(x[, n]) Generate a Van der Monde matrix. ma.polyfit(x, y, deg[, rcond, full]) Least squares polynomial fit.

Clipping and rounding¶

 ma.around Round an array to the given number of decimals. ma.clip(a, a_min, a_max[, out]) Clip (limit) the values in an array. ma.round(a[, decimals, out]) Return a copy of a, rounded to ‘decimals’ places. ma.MaskedArray.clip(a_min, a_max[, out]) Return an array whose values are limited to [a_min, a_max]. ma.MaskedArray.round([decimals, out]) Return a with each element rounded to the given number of decimals.

Miscellanea¶

 ma.allequal(a, b[, fill_value]) Return True if all entries of a and b are equal, using ma.allclose(a, b[, masked_equal, rtol, ...]) Returns True if two arrays are element-wise equal within a tolerance. ma.apply_along_axis(func1d, axis, arr, ...) Apply a function to 1-D slices along the given axis. ma.arange([dtype]) Return evenly spaced values within a given interval. ma.choose(indices, choices[, out, mode]) Use an index array to construct a new array from a set of choices. ma.ediff1d(arr[, to_end, to_begin]) Compute the differences between consecutive elements of an array. ma.indices(dimensions[, dtype]) Return an array representing the indices of a grid. ma.where(condition[, x, y]) Return a masked array with elements from x or y, depending on condition.