xarray icon indicating copy to clipboard operation
xarray copied to clipboard

ENH: Preserve attrs in to_dataframe()

Open snowman2 opened this issue 4 years ago • 6 comments

  • [x] Closes #5327
  • [x] Tests added
  • [x] Passes pre-commit run --all-files
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst

snowman2 avatar May 18 '21 21:05 snowman2

Thanks @snowman2

If you're interested, see #3497 for the inverse problem of using pandas attrs when constructing Xarray objects (in a future PR) :)

dcherian avatar May 19 '21 13:05 dcherian

Was there any reason this stalled? It looked like a good start!

max-sixty avatar Aug 28 '24 18:08 max-sixty

I believe the issue is that pandas.DataFrame does not support column attrs (or did not? I didn't check whether that changed since then). DataFrame-level attrs should work, though.

keewis avatar Aug 28 '24 19:08 keewis

They were thinking of removing it at one point: https://github.com/pandas-dev/pandas/issues/52166, also https://github.com/dask/dask/issues/11146

perhaps we should punt until someone really really wants it?

dcherian avatar Aug 28 '24 20:08 dcherian

Yes, looks like the conclusion from the pandas issue is they want to keep it but the support is spotty.

Probably we close this unless someone comes to save it, but I would vote to merge a PR that did this — I can't see a downside...

max-sixty avatar Aug 28 '24 22:08 max-sixty

hi, I just saw that this discussion has been picking up. I work on the framework mentioned in this comment https://github.com/pandas-dev/pandas/issues/52166#issuecomment-2178473375 and we would be very happy if the dataframe-level attrs would be added back to dask-dataframes. We don't use the column-level attrs but do use the df-level attrs. Currently, the solution we implement to use the latest dask is that we ask users to change the configs like so

dask.config.set({'dataframe.query-planning': False})

Would this PR preserve the attrs also in the dask-expr backend?

giovp avatar Sep 15 '24 22:09 giovp