Skip to content

Add method to summarize table column info #2999

Closed

Description

@cdeil

This is a feature request for Astropy table (related to, but separate from #2998).

HDUList has the info method that prints a summary of the HDUs in the list.
How about adding an info or summary method to Table that prints a summary of which columns it contains plus some basic stats for numerical columns plus info on the number of "good" (i.e. non-masked) elements.

As an illustration what I mean, here's what stilts tpipe does:

$ stilts tpipe ./gammapy/datasets/data/tev_catalogs/tevcat.fits.gz omode=stats
Total Rows: 173
+------------------+------------+------------+------------+-----------+------+
| column           | mean       | stdDev     | min        | max       | good |
+------------------+------------+------------+------------+-----------+------+
| canonical_name   |            |            |            |           | 173  |
| catalog_id       |            |            |            |           | 173  |
| catalog_id_name  |            |            |            |           | 173  |
| catalog_name     |            |            |            |           | 173  |
| coord_dec        | -4.2542686 | 39.261513  | -69.16583  | 72.98361  | 173  |
| coord_gal_lat    | 2.575876   | 28.594221  | -87.96714  | 83.41788  | 173  |
| coord_gal_lon    | 174.05411  | 121.33482  | 0.87189746 | 359.94485 | 173  |
| coord_ra         | 206.73235  | 93.13067   | 1.6083333  | 359.78925 | 173  |
| coord_type       | -95.566475 | 18.114359  | -99        | 0         | 173  |
| discoverer       | 7.2543354  | 3.168495   | 1          | 19        | 173  |
| discovery_date   |            |            |            |           | 173  |
| distance_value   | 73.530266  | 463.1952   | 0.00183    | 3900.0    | 126  |
| distance_type    |            |            |            |           | 124  |
| distance_kpc     | 372831.47  | 818103.4   | 0.102      | 6261886.0 | 126  |
| eth              | 1126.8209  | 4123.756   | 0.4        | 35000.0   | 143  |
| flux             | 0.1374593  | 0.26819348 | 0.0017     | 2.0       | 140  |
| id               | 163.36417  | 52.96711   | 74         | 254       | 173  |
| observatory_name |            |            |            |           | 173  |
| other_names      |            |            |            |           | 96   |
| owner            | -37.687862 | 48.745483  | -99        | 2         | 173  |
| size_x           | 0.30347693 | 0.4286603  | 0.02       | 2.6       | 65   |
| size_y           | 0.24755384 | 0.3756975  | 0.02       | 2.6       | 65   |
| source_type      | 14.433526  | 9.782161   | 1          | 37        | 173  |
| source_type_name |            |            |            |           | 173  |
| spec_idx         | 2.5542648  | 1.0718743  | -3.6       | 5.4       | 102  |
| src_rank         | -0.6820809 | 10.654184  | -99        | 1         | 173  |
| variability      | -45.11561  | 49.39926   | -99        | 2         | 173  |
+------------------+------------+------------+------------+-----------+------+

Activity

  1. astrofrog commented on Sep 30, 2014

    @astrofrog
    Member

    +1

  2. taldcroft commented on Sep 30, 2014

    @taldcroft
    Member

    👍 on info() methods for Table, Row, Column, MaskedColumn that generate useful informational summaries of these objects. Great idea. Having control of the information that gets printed via info keywords would be good. As above, a stats mode is good, but you might want basic info like unit, format, dtype.

    It should probably return some object class that has appropriate __repr__, __str__, and _html_repr_ methods. Or the simplist thing, just an Astropy Table with columns filled accordingly.

  3. rashoodkhan commented on Dec 2, 2014

    @rashoodkhan
    Contributor

    I will be interested to take this up if no one is working on it yet.

  4. astrofrog commented on Dec 2, 2014

    @astrofrog
    Member

    @rashoodkhan - I don't think anyone is working on this. Thanks for volunteering!

  5. cdeil commented on Dec 2, 2014

    @cdeil
    MemberAuthor

    Thanks @rashoodkhan !

    I think @taldcroft's suggestion of generating a new table might be best ? It means you don't have to figure out e.g. nice float formatting and it's even possible to just save it to file.

  6. rashoodkhan commented on Dec 2, 2014

    @rashoodkhan
    Contributor

    Both the options presented by @taldcroft seems good, returning an Astropy table will be easier to implement, it will be calculating/extracting data from existing table and creating a new table. I will have a look at stilts and then come up with what information we should be displaying.

  7. cdeil commented on Dec 2, 2014

    @cdeil
    MemberAuthor

    Note that stilts is GPL licensed and thus you shouldn't read their code before implementing this (I think). But you can run stilts and use it's options and output as an example while developing your code for astropy.table.

  8. rashoodkhan commented on Dec 2, 2014

    @rashoodkhan
    Contributor

    Sure thing, will keep that in mind. I will be just using its output to develop the specifications.

  9. rashoodkhan commented on Dec 8, 2014

    @rashoodkhan
    Contributor

    I am planning to implement the following information from given Column (Inspired -

    1. Mean
    2. Standard deviation
    3. Minimum value
    4. Maximum value

    Its inspired from the above example by @cdeil., Please update the above list for more options to be displayed. Along this I will work on #2998. I looked in to HDUlist.info() to see how info() was implemented.

  10. embray commented on Dec 8, 2014

    @embray
    Member

    I wouldn't really look at that :)

  11. rashoodkhan commented on Dec 8, 2014

    @rashoodkhan
    Contributor

    Yeah I realized that the functionality of info() for Table will differ a lot from HDUList.info(), as I'm pretty new to Python, I am trying to read some related code-base when working on issues. So far, its going good! 😄

  12. taldcroft commented on Dec 12, 2014

    @taldcroft
    Member

    @rashoodkhan - how's it going on this? We'd definitely like to get this in for the 1.0 release. This means a PR should be merged by next Friday, so just wondering if you think you will have time to work on this in the next week.

  13. SaOgaz commented on Jun 28, 2016

    @SaOgaz
    Contributor

    Is there still a need for this? It was kind of hard to follow all the other linked (and indirectly linked) issues. And looking at the docs, it's doesn't seem like table.info() is doing this at the moment?

  14. taldcroft commented on Jun 28, 2016

    @taldcroft
    Member

    @SaraOgaz - this is done now, closed by #3731.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions