Repository navigation
Closed
Labels
Description
This is a feature request for Astropy table row.
I often have source catalogs as Astropy tables and there are very many columns.
It's pretty hard to print a nice summary of the info for one row (often an astronomical source).
This is hard to read:
>>> table[0]
<Row 0 of table
values=('PKS 2005-489', '1', 'Default Catalog', 'TeV J2009-488', -48.83111111111111, -32.6051101920264, 350.374122051594, 302.36249999999995, -99, 6, '2005-06-01', 0.071, 'z', 323761.88688950095, 400.0, 0.03, 100, 'H.E.S.S.', 'HESS J2009-488', -99, nan, nan, 1, 'HBL', 3.2, 1, -99)
dtype=[('canonical_name', '<U21'), ('catalog_id', '<U4'), ('catalog_id_name', '<U68'), ('catalog_name', '<U14'), ('coord_dec', '>f8'), ('coord_gal_lat', '>f8'), ('coord_gal_lon', '>f8'), ('coord_ra', '>f8'), ('coord_type', '>i8'), ('discoverer', '>i8'), ('discovery_date', '<U40'), ('distance_value', '>f8'), ('distance_type', '<U12'), ('distance_kpc', '>f8'), ('eth', '>f8'), ('flux', '>f8'), ('id', '>i8'), ('observatory_name', '<U15'), ('other_names', '<U512'), ('owner', '>i8'), ('size_x', '>f8'), ('size_y', '>f8'), ('source_type', '>i8'), ('source_type_name', '<U20'), ('spec_idx', '>f8'), ('src_rank', '>i8'), ('variability', '>i8')]>This is roughly what I want ... but it would be nice to have some extra info printed (namely dtype and optionally mask and data separately) and have it displayed nicely like Table does it:
>>> list(zip(t.colnames, t[0].data))
[('canonical_name', 'PKS 2005-489'),
('catalog_id', '1'),
('catalog_id_name', 'Default Catalog'),
('catalog_name', 'TeV J2009-488'),
('coord_dec', -48.831111111111113),
('coord_gal_lat', -32.605110192026402),
('coord_gal_lon', 350.37412205159399),
('coord_ra', 302.36249999999995),
('coord_type', -99),
('discoverer', 6),
('discovery_date', '2005-06-01'),
('distance_value', 0.070999999999999994),
('distance_type', 'z'),
('distance_kpc', 323761.88688950095),
('eth', 400.0),
('flux', 0.029999999999999999),
('id', 100),
('observatory_name', 'H.E.S.S.'),
('other_names', 'HESS J2009-488'),
('owner', -99),
('size_x', nan),
('size_y', nan),
('source_type', 1),
('source_type_name', 'HBL'),
('spec_idx', 3.2000000000000002),
('src_rank', 1),
('variability', -99)]@taldcroft Is this easily possible already or do you think it's worth adding as a method on Row?
Activity
taldcroft commentedon Sep 30, 2014
By analogy with Table, this could be done with
__str__and_html_repr_, so you would do:In IPython notebook doing
t[1]would give an HTML table. Question is whether it should be horizontal or vertical, since in notebook you can have a scrollbar.embray commentedon Sep 30, 2014
Would also be worth considering adding a
_repr_pprint_though that would only work in IPython technically.embray commentedon Jul 6, 2021
This has been done since #4066.