Empty the table
Read in a table from a file/database.
Optional Keyword Arguments (independent of table type):
- verbose: [ True | False ]
- Whether to print out warnings when reading (default is True)
- type: [ string ]
- The read method attempts to automatically guess the file/database format based on the arguments supplied. The type can be overridden by setting this argument.
Write out a table to a file/database.
Optional Keyword Arguments (independent of table type):
- verbose: [ True | False ]
- Whether to print out warnings when writing (default is True)
- type: [ string ]
- The read method attempts to automatically guess the file/database format based on the arguments supplied. The type can be overridden by setting this argument.
Add a comment to the table
Required Argument:
- comment: [ string ]
- The comment to add to the table
Add a keyword/value pair to the table
Required Arguments:
- key: [ string ]
- The name of the keyword
- value: [ string | float | integer | bool ]
- The value of the keyword
Prints a description of the table
Add a column to the table
Required Arguments:
- name: [ string ]
- The name of the column to add
- data: [ numpy array ]
- The column data
Optional Keyword Arguments:
- unit: [ string ]
- The unit of the values in the column
- null: [ same type as data ]
- The values corresponding to ‘null’, if not NaN
- description: [ string ]
- A description of the content of the column
- format: [ string ]
- The format to use for ASCII printing
- dtype: [ numpy type ]
- Numpy type to convert the data to. This is the equivalent to the dtype= argument in numpy.array
- column_header: [ ColumnHeader ]
The metadata from an existing column to copy over. Metadata includes the unit, null value, description, format, and dtype. For example, to create a column ‘b’ with identical metadata to column ‘a’ in table ‘t’, use:
>>> t.add_column('b', column_header=t.columns[a])- before: [ string ]
- Column before which the new column should be inserted
- after: [ string ]
- Column after which the new column should be inserted
- position: [ integer ]
- Position at which the new column should be inserted (0 = first column)
- mask: [ numpy array ]
- An array of booleans, with the same dimensions as the data, indicating whether or not to mask values.
- fill: [ value ]
- If masked arrays are used, this value is used as the fill value in the numpy masked array.
Add an empty column to the table. This only works if there are already existing columns in the table.
Required Arguments:
- name: [ string ]
- The name of the column to add
- dtype: [ numpy type ]
- Numpy type of the column. This is the equivalent to the dtype= argument in numpy.array
Optional Keyword Arguments:
- unit: [ string ]
- The unit of the values in the column
- null: [ same type as data ]
- The values corresponding to ‘null’, if not NaN
- description: [ string ]
- A description of the content of the column
- format: [ string ]
- The format to use for ASCII printing
- column_header: [ ColumnHeader ]
The metadata from an existing column to copy over. Metadata includes the unit, null value, description, format, and dtype. For example, to create a column ‘b’ with identical metadata to column ‘a’ in table ‘t’, use:
>>> t.add_column('b', column_header=t.columns[a])- shape: [ tuple ]
- Tuple describing the shape of the empty column that is to be added. If a one element tuple is specified, it is the number of rows. If a two element tuple is specified, the first is the number of rows, and the second is the width of the column.
- before: [ string ]
- Column before which the new column should be inserted
- after: [ string ]
- Column after which the new column should be inserted
- position: [ integer ]
- Position at which the new column should be inserted (0 = first column)
Remove several columns from the table
Required Argument:
- remove_names: [ list of strings ]
- A list containing the names of the columns to remove
Keep only specific columns in the table (remove the others)
Required Argument:
- keep_names: [ list of strings ]
- A list containing the names of the columns to keep. All other columns will be removed.
Rename a column from the table
Require Arguments:
- old_name: [ string ]
- The current name of the column.
- new_name: [ string ]
- The new name for the column
Set the name of the table column that should be used as a unique identifier for the record. This is the same as primary keys in SQL databases. A primary column cannot contain NULLs and must contain only unique quantities.
Required Arguments:
- key: [ string ]
- The column to use as a primary key
Sort the table according to one or more keys. This operates on the existing table (and does not return a new table).
Required arguments:
- keys: [ string | list of strings ]
- The key(s) to order by
Returns a single row
Required arguments:
- row_number: [ integer ]
- The row number (the first row is 0)
Optional Keyword Arguments:
- python_types: [ True | False ]
- Whether to return the row elements with python (True) or numpy (False) types.
Select specific rows from the table and return a new table instance
Required Argument:
- row_ids: [ list | np.int array ]
- A python list or numpy array specifying which rows to select, and in what order.
Returns:
A new table instance, containing only the rows selected
Select matching rows from the table and return a new table instance
Required Argument:
- mask: [ np.bool array ]
- A boolean array with the same length as the table.
Returns:
A new table instance, containing only the rows selected