class craftutils.wrap.dragons.Table.MaskedColumn(craftutils.wrap.dragons.Table.Column, astropy.table._column_mixins._MaskedColumnGetitemShim, numpy.ma.core.MaskedArray)

Define a masked data column for use in a Table object.

Parameters

datalist, ndarray, or None

Column data values

namestr

Column name and key for reference within Table

masklist, ndarray or None

Boolean mask for which True indicates missing or invalid data

fill_valuefloat, int, str, or None

Value used when filling masked column elements

dtype~numpy.dtype-like

Data type for column

shapetuple or ()

Dimensions of a single row element in the column data

lengthint or 0

Number of row elements in column data

descriptionstr or None

Full description of column

unitstr or None

Physical unit

formatstr, None, or callable

Format string for outputting column values. This can be an “old-style” (format % value) or “new-style” (str.format) format specification string or a function or any callable object that accepts a single value and returns a string.

metadict-like or None

Meta-data associated with the column

Examples

A MaskedColumn is similar to a Column except that it includes mask and fill_value attributes. It can be created in two different ways:

  • Provide a data value but not shape or length (which are inferred from the data).

    Examples:

    col = MaskedColumn(data=[1, 2], name='name')
    col = MaskedColumn(data=[1, 2], name='name', mask=[True, False])
    col = MaskedColumn(data=[1, 2], name='name', dtype=float, fill_value=99)
    

    The mask argument will be cast as a boolean array and specifies which elements are considered to be missing or invalid.

    The dtype argument can be any value which is an acceptable fixed-size data-type initializer for the numpy.dtype() method. See https://numpy.org/doc/stable/reference/arrays.dtypes.html. Examples include:

    • Python non-string type (float, int, bool)

    • Numpy non-string type (e.g. np.float32, np.int64, np.bool_)

    • Numpy.dtype array-protocol type strings (e.g. ‘i4’, ‘f8’, ‘S15’)

    If no dtype value is provide then the type is inferred using np.array(data). When data is provided then the shape and length arguments are ignored.

  • Provide length and optionally shape, but not data

    Examples:

    col = MaskedColumn(name='name', length=5)
    col = MaskedColumn(name='name', dtype=int, length=10, shape=(3,4))
    

    The default dtype is np.float64. The shape argument is the array shape of a single cell in the column.

To access the Column data as a raw numpy.ma.MaskedArray object, you can use one of the data or value attributes (which are equivalent):

col.data
col.value

Public members

info

Container for meta information like name, description, format.

static MaskedColumn(cls, data=None, name=None, mask=None, ...)

Create and return a new object. See help(type) for accurate signature.

filled(fill_value=None)

Return a copy of self, with masked values filled with a given value.

insert(obj, values, mask=None, axis=0)

Insert values along the given axis before the given indices and return a new ~astropy.table.MaskedColumn object.

__setitem__(index, value)

Set self[key] to value.

copy(order='C', data=None, copy_data=True)

Return a copy of the current instance.

more(max_lines=None, show_name=True, show_unit=False)

Interactively browse column with a paging interface.

pprint(max_lines=None, show_name=True, show_unit=False, ...)

Print a formatted string representation of column values.

pformat(max_lines=None, show_name=True, show_unit=False, ...)

Return a list of formatted string representation of column values.

convert_unit_to(new_unit, equivalencies=[])

Converts the values of the column in-place from the current unit to the given unit.

__setattr__(item, value)

Implement setattr(self, name, value).

__repr__()

Return repr(self).

__str__()

Return str(self).

__eq__(other)

Return self==value.

__ne__(other)

Return self!=value.

__gt__(other)

Return self>value.

__lt__(other)

Return self<value.

__ge__(other)

Return self>=value.

__le__(other)

Return self<=value.

to(unit, equivalencies=[], **kwargs)

Converts this table column to a ~astropy.units.Quantity object with the requested units.

meta
__reduce__()

Return a 3-tuple for pickling a Column. Use the super-class functionality but then add in a 5-tuple of Column-specific values that get used in __setstate__.

__array_finalize__(obj, /)

Present so subclasses can call super. Does nothing.

__array_wrap__(out_arr, context=None)

__array_wrap__ is called at the end of every ufunc.

iter_str_vals()

Return an iterator that yields the string-formatted values of this column.

attrs_equal(col)

Compare the column attributes of col to this object.

searchsorted(v, side='left', sorter=None)

Find indices where elements of v should be inserted in a to maintain order.

group_by(keys)

Group this column by the specified keys

tolist()

Return the array as an a.ndim-levels deep nested list of Python scalars.

__getitem__(key, /)

Return self[key].

view(dtype=None, type=None, fill_value=None)

Return a view of the MaskedArray data.

__setmask__(mask, copy=False)

Set the mask.

harden_mask()

Force the mask to hard, preventing unmasking by assignment.

soften_mask()

Force the mask to soft (default), allowing unmasking by assignment.

unshare_mask()

Copy the mask and set the sharedmask flag to False.

shrink_mask()

Reduce a mask to nomask when possible.

get_fill_value()

The filling value of the masked array is a scalar. When setting, None will set to a default based on the data type.

set_fill_value(value=None)
compressed()

Return all the non-masked data as a 1-D array.

compress(condition, axis=None, out=None)

Return a where condition is True.

__add__(other)

Add self to other, and return a new masked array.

__radd__(other)

Add other to self, and return a new masked array.

__sub__(other)

Subtract other from self, and return a new masked array.

__rsub__(other)

Subtract self from other, and return a new masked array.

__mul__(other)

Multiply self by other, and return a new masked array.

__rmul__(other)

Multiply other by self, and return a new masked array.

__div__(other)

Divide other into self, and return a new masked array.

__truediv__(other)

Divide other into self, and return a new masked array.

__rtruediv__(other)

Divide self into other, and return a new masked array.

__floordiv__(other)

Divide other into self, and return a new masked array.

__rfloordiv__(other)

Divide self into other, and return a new masked array.

__pow__(other)

Raise self to the power other, masking the potential NaNs/Infs

__rpow__(other)

Raise other to the power self, masking the potential NaNs/Infs

__iadd__(other)

Add other to self in-place.

__isub__(other)

Subtract other from self in-place.

__imul__(other)

Multiply self by other in-place.

__idiv__(other)

Divide self by other in-place.

__ifloordiv__(other)

Floor divide self by other in-place.

__itruediv__(other)

True divide self by other in-place.

__ipow__(other)

Raise self to the power other, in place.

__float__()

Convert to float.

__int__()

Convert to int.

get_imag()

The imaginary part of the masked array.

get_real()

The real part of the masked array.

count(axis=None, keepdims=<no value>)

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

ravel(order='C')

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

reshape(*s, **kwargs)

Give a new shape to the array without changing its data.

resize(newshape, refcheck=True, order=False)
put(indices, values, mode='raise')

Set storage-indexed locations to corresponding values.

ids()

Return the addresses of the data and mask areas.

iscontiguous()

Return a boolean indicating whether the data is contiguous.

all(axis=None, out=None, keepdims=<no value>)

Returns True if all elements evaluate to True.

any(axis=None, out=None, keepdims=<no value>)

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

nonzero()

Return the indices of unmasked elements that are not zero.

trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)

Return the sum along diagonals of the array.

dot(b, out=None)

Masked dot product of two arrays. Note that out and strict are located in different positions than in ma.dot. In order to maintain compatibility with the functional version, it is recommended that the optional arguments be treated as keyword only. At some point that may be mandatory.

sum(axis=None, dtype=None, out=None, keepdims=<no value>)

Return the sum of the array elements over the given axis.

cumsum(axis=None, dtype=None, out=None)

Return the cumulative sum of the array elements over the given axis.

prod(axis=None, dtype=None, out=None, keepdims=<no value>)

Return the product of the array elements over the given axis.

product(axis=None, dtype=None, out=None, keepdims=<no value>)

Return the product of the array elements over the given axis.

cumprod(axis=None, dtype=None, out=None)

Return the cumulative product of the array elements over the given axis.

mean(axis=None, dtype=None, out=None, keepdims=<no value>)

Returns the average of the array elements along given axis.

anom(axis=None, dtype=None)

Compute the anomalies (deviations from the arithmetic mean) along the given axis.

var(axis=None, dtype=None, out=None, ddof=0, keepdims=<no value>)

Compute the variance along the specified axis.

std(axis=None, dtype=None, out=None, ddof=0, keepdims=<no value>)

Returns the standard deviation of the array elements along given axis.

round(decimals=0, out=None)

Return each element rounded to the given number of decimals.

argsort(axis=<no value>, kind=None, order=None, endwith=True, ...)

Return an ndarray of indices that sort the array along the specified axis. Masked values are filled beforehand to fill_value.

argmin(axis=None, fill_value=None, out=None, *, keepdims=<no value>)

Return array of indices to the minimum values along the given axis.

argmax(axis=None, fill_value=None, out=None, *, keepdims=<no value>)

Returns array of indices of the maximum values along the given axis. Masked values are treated as if they had the value fill_value.

sort(axis=- 1, kind=None, order=None, endwith=True, fill_value=None)

Sort the array, in-place

min(axis=None, out=None, fill_value=None, keepdims=<no value>)

Return the minimum along a given axis.

max(axis=None, out=None, fill_value=None, keepdims=<no value>)

Return the maximum along a given axis.

ptp(axis=None, out=None, fill_value=None, keepdims=False)

Return (maximum - minimum) along the given dimension (i.e. peak-to-peak value).

partition(kth, axis=- 1, kind='introselect', order=None)

Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array. All elements smaller than the kth element are moved before this element and all equal or greater are moved behind it. The ordering of the elements in the two partitions is undefined.

argpartition(kth, axis=- 1, kind='introselect', order=None)

Returns the indices that would partition this array.

take(indices, axis=None, out=None, mode='raise')
diagonal(offset=0, axis1=0, axis2=1)

Return specified diagonals. In NumPy 1.9 the returned array is a read-only view instead of a copy as in previous NumPy versions. In a future version the read-only restriction will be removed.

flatten(order='C')

Return a copy of the array collapsed into one dimension.

repeat(repeats, axis=None)

Repeat elements of an array.

squeeze(axis=None)

Remove axes of length one from a.

swapaxes(axis1, axis2)

Return a view of the array with axis1 and axis2 interchanged.

transpose(*axes)

Returns a view of the array with axes transposed.

tostring(fill_value=None, order='C')

A compatibility alias for tobytes, with exactly the same behavior.

tobytes(fill_value=None, order='C')

Return the array data as a string containing the raw bytes in the array.

tofile(fid, sep='', format='%s')

Save a masked array to a file in binary format.

toflex()

Transforms a masked array into a flexible-type array.

torecords()

Transforms a masked array into a flexible-type array.

__deepcopy__(memo, /) Deep copy of array.

Used if copy.deepcopy() is called on an array.

__iter__()

Implement iter(self).

__mod__(value, /)

Return self%value.

__rmod__(value, /)

Return value%self.

__divmod__(value, /)

Return divmod(self, value).

__rdivmod__(value, /)

Return divmod(value, self).

__neg__()

-self

__pos__()

+self

__abs__()

abs(self)

__bool__()

self != 0

__invert__()

~self

__lshift__(value, /)

Return self<<value.

__rlshift__(value, /)

Return value<<self.

__rshift__(value, /)

Return self>>value.

__rrshift__(value, /)

Return value>>self.

__and__(value, /)

Return self&value.

__rand__(value, /)

Return value&self.

__xor__(value, /)

Return self^value.

__rxor__(value, /)

Return value^self.

__or__(value, /)

Return self|value.

__ror__(value, /)

Return value|self.

__imod__(value, /)

Return self%=value.

__ilshift__(value, /)

Return self<<=value.

__irshift__(value, /)

Return self>>=value.

__iand__(value, /)

Return self&=value.

__ixor__(value, /)

Return self^=value.

__ior__(value, /)

Return self|=value.

__index__()

Return self converted to an integer, if self is suitable for use as an index into a list.

__matmul__(value, /)

Return self@value.

__rmatmul__(value, /)

Return value@self.

__imatmul__(value, /)

Return self@=value.

__len__()

Return len(self).

__delitem__(key, /)

Delete self[key].

__contains__(key, /)

Return key in self.

__array__(...) reference if type unchanged, copy otherwise.

Returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.

__array_prepare__(array, [context, ]/)

Returns a view of array with the same type as self.

__sizeof__()

Size of object in memory, in bytes.

__copy__()

Used if copy.copy() is called on an array. Returns a copy of the array.

__reduce_ex__()

Helper for pickle.

dumps()

Returns the pickle of the array as a string. pickle.loads will convert the string back to an array.

dump(file)

Dump a pickle of the array to the specified file. The array can be read back with pickle.load or numpy.load.

__format__()

Default object formatter.

MaskedColumn[item, /]

Return a parametrized wrapper around the ~numpy.ndarray type.

astype(dtype, order='K', casting='unsafe', subok=True, copy=True)

Copy of the array, cast to a specified type.

byteswap(inplace=False)

Swap the bytes of the array elements

choose(choices, out=None, mode='raise')

Use an index array to construct a new array from a set of choices.

clip(min=None, max=None, out=None, **kwargs)

Return an array whose values are limited to [min, max]. One of max or min must be given.

conj()

Complex-conjugate all elements.

conjugate()

Return the complex conjugate, element-wise.

fill(value)

Fill the array with a scalar value.

getfield(dtype, offset=0)

Returns a field of the given array as a certain type.

item(*args)

Copy an element of an array to a standard Python scalar and return it.

itemset(*args)

Insert scalar into an array (scalar is cast to array’s dtype, if possible)

newbyteorder(new_order='S', /)

Return the array with the same data viewed with a different byte order.

setfield(val, dtype, offset=0)

Put a value into a specified place in a field defined by a data-type.

setflags(write=None, align=None, uic=None)

Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.

__dlpack__(*, stream=None)

DLPack Protocol: Part of the Array API.

__dlpack_device__()

DLPack Protocol: Part of the Array API.

ndim

Number of array dimensions.

flags

Information about the memory layout of the array.

strides

Tuple of bytes to step in each dimension when traversing an array.

itemsize

Length of one array element in bytes.

size

Number of elements in the array.

nbytes

Total bytes consumed by the elements of the array.

base

Base object if memory is from some other object.

ctypes

An object to simplify the interaction of the array with the ctypes module.

__array_interface__

Array protocol: Python side.

__array_struct__

Array protocol: C-struct side.

__array_priority__

Array priority.

Properties

property fill_value

The filling value of the masked array is a scalar. When setting, None will set to a default based on the data type.

property data

The plain MaskedArray data held by this column.

property name

The name of this column.

property unit

The unit associated with this column. May be a string or a astropy.units.UnitBase instance.

property quantity

A view of this table column as a ~astropy.units.Quantity object with units given by the Column’s unit parameter.

property value

An alias for the existing data attribute.

property parent_table
property format

Format string for displaying values in this column.

property descr

Array-interface compliant full description of the column.

property groups
property dtype

Data-type of the array’s elements.

property shape

Tuple of array dimensions.

property mask

Current mask.

property recordmask

Get or set the mask of the array if it has no named fields. For structured arrays, returns a ndarray of booleans where entries are True if all the fields are masked, False otherwise:

property hardmask

Specifies whether values can be unmasked through assignments.

property sharedmask

Share status of the mask (read-only).

property baseclass

Class of the underlying data (read-only).

property flat

Return a flat iterator, or set a flattened version of self to value.

property imag

The imaginary part of the masked array.

property real

The real part of the masked array.

property T

View of the transposed array.