| AHELP for CIAO 4.4 | delete_col |
Context: crates |
Synopsis
Delete a column from a crate.
Syntax
delete_col(crate, colname) delete_col(crate, colnum)
Description
- crate - input table crate
- colname - column name (case insensitive)
- colnum - column number, where the first column is numbered 0
The delete_col command removes the column from the crate.
The get_col_names() routine ("ahelp get_col_names") can be used to find the columns in a Crate.
The column is only deleted from the data in the crate; it's not removed from the input file. The write_file command ("ahelp write_file") can be used to save the modified crate to a file.
Example 1
>>> cr = read_file("evt2.fits")
>>> print(get_col_names(cr))
['CHANNEL' 'COUNTS' 'STAT_ERR' 'BACKGROUND' 'BIN_LO' 'BIN_HI']
>>> delete_col(cr, "STAT_ERR")
>>> col_exists(cr, "STAT_ERR")
False
>>> write_file(cr, "nostat.fits")Delete the STAT_ERR column from the crate, then use the col_exists command to confirm it has been deleted. Write the crate to nostat.fits.
Example 2
>>> cr = read_file("evt2.fits")
>>> delete_col(cr, 4)
>>> col_exists(cr, "BACKGROUND")
False
>>> write_file(cr, "edit.fits")Delete column number 4 - the BACKGROUND column in this file - from the crate, then write the crate to file edit.fits.
Changes in CIAO 4.4
The routine no longer returns a value (1) to indicate it was succesfull.
Bugs
See the bug pages on the CIAO website for an up-to-date listing of known bugs.
Refer to the CIAO bug pages for an up-to-date listing of known issues.
See Also
- contrib
- add_colvals, make_image_crate, make_table_crate, scale_image_crate, smooth_image_crate, write_arrays, write_columns
- crates
- add_col, add_key, add_piximg, col_exists, copy_colvals, delete_key, delete_piximg, get_col, get_col_names, get_colvals, get_number_cols, is_virtual, read_file, read_pha, read_rmf, set_colvals, write_file, write_pha, write_rmf

![[CIAO Logo]](../imgs/ciao_logo_navbar.gif)