Can't add row to table with, e.g., SkyCoord column
See original GitHub issueStarting with the documented way of making a table:
from astropy.table import Table
from astropy.time import Time
from astropy.coordinates import SkyCoord
tm = Time(['2000:002', '2002:345'])
sc = SkyCoord([10, 20], [-45, +40], unit='deg')
t = Table([tm, sc], names=['time', 'skycoord'])
print(t)
gives
time skycoord
deg,deg
--------------------- ----------
2000:002:00:00:00.000 10.0,-45.0
2002:345:00:00:00.000 20.0,40.0
But if I try to add another row:
# Add another row
t.add_row((Time('2017:001'),sc[0]))
I get
ValueError: Unable to insert row because of exception in column 'time':
'Time' object has no attribute 'insert'
Trying different things:
t = Table([[tm[0]],[sc[0]]], names=['time', 'skycoord'])
t.add_row([tm[1],sc[1]])
works giving:
time skycoord
--------------------- ----------------------------------------------------
2000:002:00:00:00.000 <SkyCoord (ICRS): (ra, dec) in deg
( 10., -45.)>
2002:345:00:00:00.000 <SkyCoord (ICRS): (ra, dec) in deg
( 20., 40.)>
So if you use astropy array objects, you can’t add rows. But if you use scalar values, you can add rows and later extract the values as a list .
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
SkyCoord — Astropy v5.2
A convenience method to create and return a new SkyCoord from the data in an astropy Table. This method matches table columns that...
Read more >Table — Astropy v5.2
Add a new row to the end of the table. The vals argument can be: sequence (e.g. tuple or list). Column values in...
Read more >Source code for astropy.table.operations
Convert inputs (Table, Row, or anything column-like) to Tables. ... TypeError) as err: raise TypeError(f'Cannot convert {val} to table column.
Read more >Table Operations — Astropy v5.2
The groups property is the portal to all grouped operations with tables and columns. It defines how the table is grouped via an...
Read more >Constructing a Table — Astropy v5.2
These can be used to create a Table by putting the column data variables ... a new table by selecting columns and putting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would naively say yes, but let’s ping the coordinates maintainers @eteq @adrn to comment on it.
I have a feeling that the code involved to introduce an
insert
property toSkyCoord
would be a lot more complicated than for eitherTime
orQuantity
…