Column

class astropy.table.table.Column [edit on github][source]

Bases: astropy.table.table.BaseColumn, numpy.ndarray

Define a data column for use in a Table object.

Parameters :

name : str

Column name and key for reference within Table

data : list, ndarray or None

Column data values

dtype : numpy.dtype compatible value

Data type for column

shape : tuple or ()

Dimensions of a single row element in the column data

length : int or 0

Number of row elements in column data

description : str or None

Full description of column

units : str or None

Physical units

format : str or None

Format string for outputting column values. This can be an “old-style” (format % value) or “new-style” (str.format) format specification string.

meta : dict-like or None

Meta-data associated with the column

Examples

A Column can be created in two different ways:

  • Provide a data value and optionally a dtype value

    Examples:

    col = Column('name', data=[1, 2, 3])         # shape=(3,)
    col = Column('name', data=[[1, 2], [3, 4]])  # shape=(2, 2)
    col = Column('name', data=[1, 2, 3], dtype=float)
    col = Column('name', np.array([1, 2, 3]))
    col = Column('name', ['hello', 'world'])
    

    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:

    • 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 zero or more of dtype, shape, length

    Examples:

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

    The default dtype is np.float64 and the default length is zero. The shape argument is the array shape of a single cell in the column. The default shape is () which means a single value in each element.

Attributes Summary

data

Methods Summary

copy([data, copy_data]) Return a copy of the current Column instance.

Attributes Documentation

data[source]

Methods Documentation

copy(data=None, copy_data=True) [edit on github][source]

Return a copy of the current Column instance.

Page Contents