Skip to content

String coords broken in pandas git tip #10553

@crusaderky

Description

@crusaderky

DataArray.expand_dims with the new coords passed as keyword arguments recently broke in pandas nightly.

import xarray

ab = xarray.DataArray([1, 2], dims=['x'], coords={'x': ['a', 'b']})
c = xarray.DataArray(3).expand_dims(x=["c"])
# c.coords["x"] = c.coords["x"].values
arr = xarray.concat([ab, c], dim="x")

crashes with

TypeError: Cannot interpret '<StringDtype(storage='python', na_value=nan)>' as a data type

Uncommenting the third line, which overwrites the coord with a numpy array copy of itself, works around the problem.

It broke somewhere between 3.0.0.dev0+2231 and 3.0.0.dev0+2248; I did not bisect it exactly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions