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
mask : numpy ndarray, dict, list, optional
names : list, optional
dtypes : list, optional
meta : dict, optional
copy : boolean, optional
|
---|
Attributes Summary
masked | |
colnames | |
dtype | |
ColumnClass | |
mask |
Methods Summary
create_mask() | |
rename_column(name, new_name) | Rename a column. |
pprint([max_lines, max_width, show_name, ...]) | Print a formatted string representation of the table. |
index_column(name) | Return the positional index of column name. |
next() | Python 3 iterator |
write(*args, **kwargs) | Write a table |
field(item) | Return column[item] for recarray compatibility. |
add_column(col[, index]) | Add a new Column object col to the table. |
filled([fill_value]) | Return a copy of self, with masked values filled. |
more([max_lines, max_width, show_name, ...]) | Interactively browse table with a paging interface. |
sort(keys) | Sort the table according to one or more keys. |
keys() | |
remove_columns(names) | Remove several columns from the table |
reverse() | Reverse the row order of table rows. |
read(*args, **kwargs) | Read a table |
add_columns(cols[, indexes]) | Add a list of new Column objects cols to the table. |
keep_columns(names) | Keep only the columns specified (remove the others). |
remove_column(name) | Remove a column from the table. |
pformat([max_lines, max_width, show_name, ...]) | Return a list of lines for the formatted string representation of the table. |
add_row([vals, mask]) | Add a new row to the end of the table. |
Attributes Documentation
Methods Documentation
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
|
---|
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
|
---|
Return the positional index of column name.
Parameters : | name : str
|
---|---|
Returns : | index : int
|
Python 3 iterator
Write a table
The arguments passed to this method depend on the format
Return column[item] for recarray compatibility.
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
|
---|
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
|
---|
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
|
---|
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
|
---|
Remove several columns from the table
Parameters : | names : list
|
---|
Reverse the row order of table rows. The table is reversed in place and there are no function arguments.
Read a table
The arguments passed to this method depend on the format
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
|
---|
Keep only the columns specified (remove the others).
Parameters : | names : list
|
---|
Remove a column from the table.
This can also be done with:
del table[name]
Parameters : | name : str
|
---|
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
|
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
|
---|