Bases: object
A class to represent tables of heterogeneous data.
Table provides a class for heterogeneous tabular data, making use of a numpy structured array internally to store the data values. A key enhancement provided by the Table class 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.
Table differs from 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 units, format, and description.
Parameters : | data : numpy ndarray, dict, list, or Table, optional
masked : boolean, optional
names : list, optional
dtypes : list, optional
meta : dict, optional
copy : boolean, optional
|
---|
Attributes Summary
ColumnClass | |
colnames | |
dtype | |
mask | |
masked | |
meta |
Methods Summary
add_column(col[, index]) | Add a new Column object col to the table. |
add_columns(cols[, indexes]) | Add a list of new Column objects cols to the table. |
add_row([vals, mask]) | Add a new row to the end of the table. |
create_mask() | |
field(item) | Return column[item] for recarray compatibility. |
filled([fill_value]) | Return a copy of self, with masked values filled. |
index_column(name) | Return the positional index of column name. |
keep_columns(names) | Keep only the columns specified (remove the others). |
keys() | |
more([max_lines, max_width, show_name, ...]) | Interactively browse table with a paging interface. |
next() | Python 3 iterator |
pformat([max_lines, max_width, show_name, ...]) | Return a list of lines for the formatted string representation of the table. |
pprint([max_lines, max_width, show_name, ...]) | Print a formatted string representation of the table. |
read(*args, **kwargs) | Read in data |
remove_column(name) | Remove a column from the table. |
remove_columns(names) | Remove several columns from the table |
rename_column(name, new_name) | Rename a column. |
reverse() | Reverse the row order of table rows. |
sort(keys) | Sort the table according to one or more keys. |
write(data, *args, **kwargs) | Write out data |
Attributes Documentation
Methods Documentation
Add a new Column object col to the table. If index is supplied then insert column before index position in the list of columns, otherwise append column to the end of the list.
Parameters : | col : Column
index : int or None
|
---|
Add a list of new Column objects cols to the table. 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.
Parameters : | cols : list of Columns
indexes : list of ints or None
|
---|
Add a new row to the end of the table.
The vals argument can be:
This method requires that the Table object “owns” the underlying array data. In particular one cannot add a row to a Table that was initialized with copy=False from an existing array.
The mask attribute should give (if desired) the mask for the values. The type of the mask should match that of the values, i.e. if vals is an iterable, then mask should also be an iterable with the same length, and if vals is a mapping, then mask should be a dictionary.
Parameters : | vals : tuple, list, dict or None
|
---|
Return column[item] for recarray compatibility.
Return a copy of self, with masked values filled.
If input fill_value supplied then that value is used for all masked entries in the table. Otherwise the individual fill_value defined for each table column is used.
Returns : | filled_table : Table
|
---|
Return the positional index of column name.
Parameters : | name : str
|
---|---|
Returns : | index : int
|
Keep only the columns specified (remove the others).
Parameters : | names : list
|
---|
Interactively browse table with a paging interface.
Supported keys:
f, <space> : forward one page
b : back one page
r : refresh same page
n : next row
p : previous row
< : go to beginning
> : go to end
q : quit browsing
h : print this help
Parameters : | max_lines : int
max_width : int or None
show_name : bool
show_units : bool
|
---|
Python 3 iterator
Return a list of lines for the formatted string representation of the table.
If no value of max_lines is supplied then the height of the screen terminal is used to set max_lines. If the terminal height cannot be determined then the default is taken from the configuration item astropy.table.pprint.MAX_LINES. If a negative value of max_lines is supplied then there is no line limit applied.
The same applies for max_width except the configuration item is astropy.table.pprint.MAX_WIDTH.
Parameters : | max_lines : int or None
max_width : int or None
show_name : bool
show_units : bool
html : bool
|
---|---|
Returns : | lines : list
|
Print a formatted string representation of the table.
If no value of max_lines is supplied then the height of the screen terminal is used to set max_lines. If the terminal height cannot be determined then the default is taken from the configuration item astropy.table.pprint.MAX_LINES. If a negative value of max_lines is supplied then there is no line limit applied.
The same applies for max_width except the configuration item is astropy.table.pprint.MAX_WIDTH.
Parameters : | max_lines : int
max_width : int or None
show_name : bool
show_units : bool
|
---|
Read in data
The arguments passed to this method depend on the format
Remove a column from the table.
This can also be done with:
del table[name]
Parameters : | name : str
|
---|
Remove several columns from the table
Parameters : | names : list
|
---|
Rename a column.
This can also be done directly with by setting the name attribute for a column:
table[name].name = new_name
Parameters : | name : str
new_name : str
|
---|
Reverse the row order of table rows. The table is reversed in place and there are no function arguments.
Sort the table according to one or more keys. This operates on the existing table and does not return a new table.
Parameters : | keys : str or list of str
|
---|
Write out data
The arguments passed to this method depend on the format