[AstroPy] Lower(Upper)case astropy table columns

Alexander Joseph Conley Alexander.Conley at Colorado.EDU
Wed Feb 26 11:33:18 EST 2014


for colname in t.colnames:
   t.rename_column(colname, colname.lower())

But if you need to be able to use -either- ‘ra’ or ‘RA’
I don’t know a way.

Alex

On 26-Feb-2014, at 9:23 AM, Eduardo Bañados Torres <eebanado at uc.cl> wrote:

> Hi all,
> 
> is there a way to lower case the columns of a table? I have tables that sometimes come with the uppercase and other lowercase keywords. By now I am just using try/except but this gets messy when the number of columns is large. I was expecting to exist something like:
> 
> table.colnames.lower()
> 
> Is there something like that? or how could I work this around
> 
> Thanks!
> 
> Eduardo Bañados
> 
> -------------------------------------
> 
> For example
> from astropy.table import Table
> import numpy as np
> 
> t = Table(arr, names=('RA', 'DEC', 'REDSHIFT'))
> t['RA']
> #<Column name='RA' unit=None format=None description=None>
> #array([ 0,  3,  6,  9, 12])
> #I can access the table by t['RA']
> #but I need to lowercase the columns to access them as
> t['ra']
> #KeyError: 'ra'
> 
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy




More information about the AstroPy mailing list