Tuesday, April 19, 2016

Poking around with Pandas

Over a beer, Wify told me that I should be using Pandas data frames to read my file of filenames and redshifts.
import pandas
pspecs = pandas.read_table(thelist, delim_whitespace=True, comment="#")p.info()
pspecs.describe()
pspecs[(pspecs.z_ISM > 3)].reset_index()  # only those w redshift >3  
This is an exciting start! Clearly, this is a better way for this type of file than astropy's tables, because I can *sort* (high redshift, only spectra with continuum fits, etc.)

More ways to sort that Pandas data frame:
  wcont =   pspecs[pspecs['filename'].str.contains('combwC1')].reset_index()  # only w continuum
  filtlist = pspecs[pspecs['short_label'].isin(labels)].reset_index()  # only galaxies w certain names


No comments:

Post a Comment