Skip to content

ENH: Preserve attrs when converting to pandas dataframe #5327

Open
@snowman2

Description

@snowman2

Is your feature request related to a problem? Please describe.

import xarray

xds = xarray.DataArray([1], name="a", dims="a", attrs={"long_name": "Description about data"})
xds.attrs

Output:

{'long_name': 'Description about data'}
xds.to_dataframe().a.attrs

Output:

{}

Describe the solution you'd like
It would be nice if the attributes of the DataArray were preserved in each pandas.Series and the attributes of each Dataset were preserved on the pandas.Dataframe

Additional context

Things to be wary about is that it the pandas documentation says the attrs is experimental.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions