Home » Uncategorized » Re-formatting tables with astropy

Re-formatting tables with astropy

The fact that astropy is a very powerful tool is certainly well known these days, but I would like to briefly express my admiration especially for the Table package. This package allows, among many other things, to quickly convert tables between various formats (ASCII, CSV, LaTeX, many others) and it also allows to re-format individual columns. For example, if you would like to change the number of significant digits for a specific column (“seeing”), you simply open the table and assign the usual format specifier to this column like this:

from astropy.io import ascii

a=ascii.read(“table.tex”)

a[“seeing”].format=”%5.2f”

a.write(“table_reformatted.tex”)

My Tweets