Bases: astropy.table.table.BaseColumn, numpy.ndarray
Define a data column for use in a Table object.
Parameters: | data : list, ndarray or None
name : str
dtype : numpy.dtype compatible value
shape : tuple or ()
length : int or 0
description : str or None
unit : str or None
format : str or None or function
meta : dict-like or None
|
---|
Examples
A Column can be created in two different ways:
Provide a data value but not shape or length (which are inferred from the data).
Examples:
col = Column(data=[1, 2], name='name') # shape=(2,)
col = Column(data=[[1, 2], [3, 4]], name='name') # shape=(2, 2)
col = Column(data=[1, 2], name='name', dtype=float)
col = Column(data=np.array([1, 2]), name='name')
col = Column(data=['hello', 'world'], name='name')
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).
Provide length and optionally shape, but not data
Examples:
col = Column(name='name', length=5)
col = Column(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 Column will change. Currently the order is Column(name, data, ...), but in 0.3 and later it will be Column(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 = Column(data=[1, 2], name='col'). When Astropy 0.3 is released then the the keyword identifiers can be dropped, allowing for c = Column([1, 2], 'c').
Attributes Summary
data |
Methods Summary
copy([order, data, copy_data]) | Return a copy of the current Column instance. |
Attributes Documentation
Methods Documentation
Return a copy of the current Column instance. If data is supplied then a view (reference) of data is used, and copy_data is ignored.