class craftutils.wrap.dragons.Table

A class to represent tables of heterogeneous data.

~astropy.table.Table provides a class for heterogeneous tabular data. A key enhancement provided by the ~astropy.table.Table class over e.g. a numpy structured array is the ability to easily modify the structure of the table by adding or removing columns, or adding new rows of data. In addition table and column metadata are fully supported.

~astropy.table.Table differs from ~astropy.nddata.NDData by the assumption that the input data consists of columns of homogeneous data, where each column has a unique identifier and may contain additional metadata such as the data unit, format, and description.

See also: https://docs.astropy.org/en/stable/table/

Parameters

datanumpy ndarray, dict, list, table-like object, optional

Data to initialize table.

maskedbool, optional

Specify whether the table is masked.

nameslist, optional

Specify column names.

dtypelist, optional

Specify column data types.

metadict, optional

Metadata associated with the table.

copybool, optional

Copy the input data. If the input is a Table the meta is always copied regardless of the copy parameter. Default is True.

rowsnumpy ndarray, list of list, optional

Row-oriented data for table instead of data argument.

copy_indicesbool, optional

Copy any indices in the input data. Default is True.

unitslist, dict, optional

List or dict of units to apply to columns.

descriptionslist, dict, optional

List or dict of descriptions to apply to columns.

**kwargsdict, optional

Additional keyword args when converting table-like object.

Public members

meta
read = <astropy.table.connect.TableRead object>
write = <astropy.table.connect.TableWrite object>
pprint_exclude_names

Maintain tuple that controls table column visibility for print output.

pprint_include_names

Maintain tuple that controls table column visibility for print output.

as_array(keep_byteorder=False, names=None)

Return a new copy of the table in the form of a structured np.ndarray or np.ma.MaskedArray object (as appropriate).

Table(data=None, masked=False, names=None, dtype=None, ...)

Initialize self. See help(type(self)) for accurate signature.

filled(fill_value=None)

Return copy of self, with masked values filled.

add_index(colnames, engine=None, unique=False)

Insert a new index among one or more columns. If there are no indices, make this index the primary table index.

remove_indices(colname)

Remove all indices involving the given column. If the primary index is removed, the new primary index will be the most recently added remaining index.

index_mode(mode)

Return a context manager for an indexing mode.

__array__(dtype=None)

Support converting Table to np.array via np.array(table).

itercols()

Iterate over the columns of this table.

__repr__()

Return repr(self).

__str__()

Return str(self).

pprint(max_lines=None, max_width=None, show_name=True, ...)

Print a formatted string representation of the table.

pprint_all(max_lines=- 1, max_width=- 1, show_name=True, ...)

Print a formatted string representation of the entire table.

show_in_notebook(tableid=None, css=None, display_length=50, ...)

Render the table in HTML and show it in the IPython notebook.

show_in_browser(max_lines=5000, jsviewer=False, ...)

Render the table in HTML and show it in a web browser.

pformat(max_lines=None, max_width=None, show_name=True, ...)
Return a list of lines for the formatted string representation of

the table.

pformat_all(max_lines=- 1, max_width=- 1, show_name=True, ...)
Return a list of lines for the formatted string representation of

the entire table.

more(max_lines=None, max_width=None, show_name=True, ...)

Interactively browse table with a paging interface.

__getitem__(item)
__setitem__(item, value)
field(item)

Return column[item] for recarray compatibility.

keys()
values()
items()
index_column(name)

Return the positional index of column name.

add_column(col, index=None, name=None, rename_duplicate=False, ...)

Add a new column to the table using col as input. If index is supplied then insert column before index position in the list of columns, otherwise append column to the end of the list.

add_columns(cols, indexes=None, names=None, copy=True, ...)

Add a list of new columns the table using cols data objects. If a corresponding list of indexes is supplied then insert column before each index position in the original list of columns, otherwise append columns to the end of the list.

replace_column(name, col, copy=True)

Replace column name with the new col object.

remove_row(index)

Remove a row from the table.

remove_rows(row_specifier)

Remove rows from the table.

iterrows(*names)

Iterate over rows of table returning a tuple of values for each row.

remove_column(name)

Remove a column from the table.

remove_columns(names)

Remove several columns from the table.

convert_bytestring_to_unicode()

Convert bytestring columns (dtype.kind=’S’) to unicode (dtype.kind=’U’) using UTF-8 encoding.

convert_unicode_to_bytestring()

Convert unicode columns (dtype.kind=’U’) to bytestring (dtype.kind=’S’) using UTF-8 encoding.

keep_columns(names)

Keep only the columns specified (remove the others).

rename_column(name, new_name)

Rename a column.

rename_columns(names, new_names)

Rename multiple columns.

add_row(vals=None, mask=None)

Add a new row to the end of the table.

insert_row(index, vals=None, mask=None)

Add a new row before the given index position in the table.

update(other, copy=True)

Perform a dictionary-style update and merge metadata.

argsort(keys=None, kind=None, reverse=False)

Return the indices which would sort the table according to one or more key columns. This simply calls the numpy.argsort function on the table with the order parameter set to keys.

sort(keys=None, *, kind=None, reverse=False)

Sort the table according to one or more keys. This operates on the existing table and does not return a new table.

reverse()

Reverse the row order of table rows. The table is reversed in place and there are no function arguments.

round(decimals=0)

Round numeric columns in-place to the specified number of decimals. Non-numeric columns will be ignored.

copy(copy_data=True)

Return a copy of the table.

__lt__(other)

Return self<value.

__gt__(other)

Return self>value.

__le__(other)

Return self<=value.

__ge__(other)

Return self>=value.

__eq__(other)

Return self==value.

__ne__(other)

Return self!=value.

values_equal(other)

Element-wise comparison of table with another table, list, or scalar.

group_by(keys)

Group this table by the specified keys

to_pandas(index=None, use_nullable_int=True)

Return a pandas.DataFrame instance

classmethod from_pandas(dataframe, index=False, units=None)

Create a ~astropy.table.Table from a pandas.DataFrame instance

info

Classes

class Row

A class to represent one row of a Table object.

class Column(astropy.table.column.BaseColumn)

Define a data column for use in a Table object.

class 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.

class TableColumns(collections.OrderedDict)

OrderedDict subclass for a set of columns.

class TableFormatter

Properties

property mask
property indices

Return the indices associated with columns of the table as a TableIndices object.

property loc

Return a TableLoc object that can be used for retrieving rows by index in a given data range. Note that both loc and iloc work only with single-column indices.

property loc_indices

Return a TableLocIndices object that can be used for retrieving the row indices corresponding to given table index key value or values.

property iloc

Return a TableILoc object that can be used for retrieving indexed rows in the order they appear in the index.

property has_mixin_columns

True if table has any mixin columns (defined as columns that are not Column subclasses).

property has_masked_columns

True if table has any MaskedColumn columns.

property has_masked_values

True if column in the table has values which are masked.

property masked
property ColumnClass
property dtype
property colnames
property groups