[AstroPy] Lower(Upper)case astropy table columns

Aldcroft, Thomas aldcroft at head.cfa.harvard.edu
Wed Feb 26 12:07:49 EST 2014


On Wed, Feb 26, 2014 at 11:33 AM, Alexander Joseph Conley <
Alexander.Conley at colorado.edu> wrote:

> 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.
>

It isn't possible with the current Table implementation.  It should be
possible to subclass Table (and probably Row, TableColumns) to do this, but
might not be entirely trivial.

- Tom



>
> 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
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140226/f6125cc0/attachment.html>


More information about the AstroPy mailing list