Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion xarray/core/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ def join(
else:
# how = "inner"
index = self.index.intersection(other.index)

if is_allowed_extension_array_dtype(index.dtype):
return type(self)(index, self.dim)
coord_dtype = np.result_type(self.coord_dtype, other.coord_dtype)
return type(self)(index, self.dim, coord_dtype=coord_dtype)

Expand Down
19 changes: 19 additions & 0 deletions xarray/tests/test_combine.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import datetime
import re
from itertools import product

import numpy as np
import pandas as pd
import pytest
import pytz

from xarray import (
DataArray,
Expand Down Expand Up @@ -1155,6 +1158,22 @@ def test_combine_by_coords_override_order(self) -> None:
actual = combine_by_coords([x2, x1], compat="override")
assert_equal(actual["a"], x2["a"])

def test_combine_by_coords_extension_array(self) -> None:
# regression test for https://github.com/pydata/xarray/issues/11235
arrs = []
expected_vals = []
for i in range(2):
t = datetime.datetime(2026, 3, 1, hour=i).astimezone(pytz.timezone("UTC"))
expected_vals += [t]
da = DataArray().expand_dims(
time=[t],
dummy=[i],
)
arrs.append(da)
expected = pd.array(expected_vals)
result = combine_by_coords(arrs, join="outer")
pd.testing.assert_extension_array_equal(result["time"].data, expected)


class TestCombineMixedObjectsbyCoords:
def test_combine_by_coords_mixed_unnamed_dataarrays(self):
Expand Down
Loading