Skip to content

DOC: add documentation on why astropy has tables - #17520

Merged
taldcroft merged 9 commits into
astropy:mainfrom
taldcroft:tables-docs-intro-why-not-pandas
Dec 11, 2024
Merged

taldcroft merged 9 commits into
astropy:mainfrom
taldcroft:tables-docs-intro-why-not-pandas

Conversation

@taldcroft

@taldcroft taldcroft commented Dec 7, 2024 •

Copy link
Copy Markdown
Member

Description

This pull request is to address a common question of why astropy maintains its own Table class instead of using pandas DataFrame.

It also tightens up the opening description and feature list.

This also substantially updates the page on Interfacing with the Pandas Package. Some of that was out of date or just wrong, so I fixed things and added a detailed example highlighting known issues.

Fixes #17146

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

github-actions Bot commented Dec 7, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@taldcroft taldcroft added this to the v7.0.1 milestone Dec 7, 2024
@taldcroft taldcroft changed the title Add documentation on why not pandas for tables DOC: add documentation on why not pandas for tables Dec 7, 2024

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the text very much. My main question is whether this is not better as a separate page, as in the main text it seems a bit distracting. A separate page would also more easily allow (others) to add more detailed information about transformations between QTable and pandas. Maybe a new interoperability.rst?

@taldcroft taldcroft changed the title DOC: add documentation on why not pandas for tables DOC: add documentation on why astropy has tables Dec 8, 2024
@taldcroft

Copy link
Copy Markdown
Member Author

@mhvk - good idea with the new page. I also took the opportunity to make this more positive at the top level. More of a "Why astropy table" rather than "Why not pandas", along with the relationship between the two. Also added a mention of polars at the end.

@taldcroft

Copy link
Copy Markdown
Member Author

@mhvk - I also substantially updated the page on Interfacing with the Pandas Package. Some of that was out of date or just wrong, so I fixed things and added a detailed example highlighting known issues.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I found a small typo, but otherwise I think we should just get it in.

Comment thread docs/table/pandas.rst Resolved
@taldcroft
taldcroft enabled auto-merge (squash) December 8, 2024 20:30
@taldcroft

Copy link
Copy Markdown
Member Author

Thanks for the quick review @mhvk. Auto-merge is enabled.

@taldcroft

taldcroft commented Dec 8, 2024 •

Copy link
Copy Markdown
Member Author

@mhvk - this is failing tests because of the new functions matvec and vecmat in numpy 2.2.0 that was just released. Quantity is not happy with numpy ufuncs that are not in quantity.

@neutrinoceros

Copy link
Copy Markdown
Contributor

Patched in #17523

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some comments, mostly for clarification.

Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Outdated
- :ref:`Time formats <time-format>` used in astronomy such as the FITS time format are
not supported.

Pandas does not support coordinate columns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is significant, maybe you want to divide this section into two, one for time and one for coordinates?

@bsipocz

bsipocz commented Dec 9, 2024

Copy link
Copy Markdown
Member

btw, just a small suggestion: if review is requested over the weekend it would be a courtesy of not setting up auto-merge before that very same weekend ended.

@pllim
pllim disabled auto-merge December 9, 2024 17:53
@pllim

pllim commented Dec 9, 2024

Copy link
Copy Markdown
Member

I disabled auto merge for now since there are new comments. FYI.

@taldcroft
taldcroft force-pushed the tables-docs-intro-why-not-pandas branch from 278d9bb to f20ab4b Compare December 9, 2024 20:23

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsipocz - thanks for the comments, I think I've addressed them. Sorry about the auto-merge, I got a bit excited to get this in.

Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Outdated
Comment on lines +46 to +48
example, accessing metadata like units is a key component of using the
`astroquery <https://astroquery.readthedocs.io/en/latest/>`_ service for astronomical
data analysis.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get the astroquery reference, and why this is a key component for astroquery. We could return whatever comes back from the server, typically a VOTable or csv or whatever text file object. It's just a compatibility thing that we went a step further and parse the results into an astropy Table.

(and returning pandas definitely brought up by a couple of modules but we pushed them to do astropy Tables instead to be more consistent with the older modules).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO a key feature of astroquery is exactly the hard work of parsing heterogenous results from data providers into a uniform and predictable data structure (QTable) that is easy for users to work with. Many of those datasets include physical quantities with units, column descriptions, or other metadata, so if astroquery returned a DataFrame then that information would be lost.

That said, if you really don't want this shout-out to astroquery then I can replace it with a different example.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded - for me part of the beauty of astroquery is exactly that it produces a table with usable columns!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think if you can go with a different example it would be OK as I'm just not comfortable with the
is a key component of using the astroquery service for astronomical data analysis summary, and nitpicking the sentence away is not very constructive.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some comments below but overall looks good.

Comment thread docs/table/index.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
Comment thread docs/table/index.rst Resolved
Comment thread docs/table/pandas.rst Resolved
Comment thread docs/table/table_and_dataframes.rst Resolved
@taldcroft

Copy link
Copy Markdown
Member Author

OK all the @pllim comments are addressed, I think.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reread, and like it very much still! One suggestion for the stop, to make the pandas reference just one item.

Comment thread docs/table/index.rst
* :ref:`Read and write <read_write_tables>` to files via the :ref:`Unified File Read/Write Interface <table_io>`.
* Convert to and from `pandas.DataFrame`.

The :ref:`astropy-table-and-dataframes` page provides the rationale for maintaining

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this as part of the item just above -- maybe

* Convert to and from `pandas.DataFrame` (see :ref:`pandas`
 as well as :ref:`astropy-table-and-dataframes` for the rationale
 for a dedicated `astropy.table` package instead of relying on `pandas`).

(not sure I got the references quite right - want to have a direct link to pandas.rst as well...)

p.s. Fine to ignore!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the rendered HTML again, I saw that every list item was succinct and fit on one line, with the exception of the one about mixins. So instead of making the pandas line longer, I shortened the mixin line and now it looks very clean.

This of course leaves the part about astropy-table-and-dataframes as a distinct coda to the introduction, but this comes up so often that it seems OK.

@taldcroft
taldcroft force-pushed the tables-docs-intro-why-not-pandas branch from 132533e to 2ab135a Compare December 11, 2024 10:04
@taldcroft
taldcroft enabled auto-merge (squash) December 11, 2024 10:13
@taldcroft
taldcroft merged commit 82e9f41 into astropy:main Dec 11, 2024
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Dec 11, 2024
@taldcroft
taldcroft deleted the tables-docs-intro-why-not-pandas branch December 11, 2024 10:55
pllim added a commit that referenced this pull request Dec 11, 2024
…520-on-v7.0.x

Backport PR #17520 on branch v7.0.x (DOC: add documentation on why astropy has tables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Why use astropy Table/QTable over pandas DataFrame

5 participants