Bases: astropy.table.table.BaseColumn, numpy.ma.core.MaskedArray
Define a masked data column for use in a Table object.
Parameters: | name : str
data : list, ndarray or None
mask : list, ndarray or None
fill_value : float, int, str or None
dtype : numpy.dtype compatible value
shape : tuple or ()
length : int or 0
description : str or None
units : str or None
format : str or None
meta : dict-like or None
|
---|
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 http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html. Examples include:
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.
Warning
In the next major release of astropy (0.3), the order of function arguments for creating a MaskedColumn will change. Currently the order is MaskedColumn(name, data, ...), but in 0.3 and later it will be MaskedColumn(data, name, ...). This improves consistency with Table and numpy.
In order to use the same code for Astropy 0.2 and 0.3, column objects should always be created using named keyword arguments for data and name, for instance c = MaskedColumn(data=[1, 2], name='col'). When Astropy 0.3 is released then the the keyword identifiers can be dropped, allowing for c = MaskedColumn([1, 2], 'c').
Attributes Summary
data | |
fill_value |
Methods Summary
copy([data, copy_data]) | Return a copy of the current MaskedColumn instance. |
filled([fill_value]) | Return a copy of self, with masked values filled with a given value. |
Attributes Documentation
Methods Documentation
Return a copy of the current MaskedColumn instance. If data is supplied then a view (reference) of data is used, and copy_data is ignored.
Parameters: | data : array; optional
copy_data : boolean; optional
|
---|---|
Returns: | column : MaskedColumn
|
Return a copy of self, with masked values filled with a given value.
Parameters: | fill_value : scalar; optional
|
---|---|
Returns: | filled_column : Column
|