Skip to content

Commit 83f238a

Browse files
authored
Fix concat with scalar coordinate (#6385)
1 parent 067b2e8 commit 83f238a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

xarray/core/concat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def get_indexes(name):
532532
elif name == dim:
533533
var = ds._variables[name]
534534
if not var.dims:
535-
yield PandasIndex([var.values], dim)
535+
yield PandasIndex([var.values.item()], dim)
536536

537537
# stack up each variable and/or index to fill-out the dataset (in order)
538538
# n.b. this loop preserves variable order, needed for groupby.

xarray/tests/test_concat.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,22 @@ def test_concat_promote_shape(self) -> None:
440440
expected = Dataset({"z": (("x", "y"), [[-1], [1]])}, {"x": [0, 1], "y": [0]})
441441
assert_identical(actual, expected)
442442

443+
# regression GH6384
444+
objs = [
445+
Dataset({}, {"x": pd.Interval(-1, 0, closed="right")}),
446+
Dataset({"x": [pd.Interval(0, 1, closed="right")]}),
447+
]
448+
actual = concat(objs, "x")
449+
expected = Dataset(
450+
{
451+
"x": [
452+
pd.Interval(-1, 0, closed="right"),
453+
pd.Interval(0, 1, closed="right"),
454+
]
455+
}
456+
)
457+
assert_identical(actual, expected)
458+
443459
def test_concat_do_not_promote(self) -> None:
444460
# GH438
445461
objs = [

0 commit comments

Comments
 (0)