Skip to content

Commit c3224ef

Browse files
authored
Avoid recasting a CFTimeIndex (#7735)
xref #7730
1 parent a1f5245 commit c3224ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xarray/core/indexes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _repr_inline_(self, max_width):
135135
def _maybe_cast_to_cftimeindex(index: pd.Index) -> pd.Index:
136136
from xarray.coding.cftimeindex import CFTimeIndex
137137

138-
if len(index) > 0 and index.dtype == "O":
138+
if len(index) > 0 and index.dtype == "O" and not isinstance(index, CFTimeIndex):
139139
try:
140140
return CFTimeIndex(index)
141141
except (ImportError, TypeError):

0 commit comments

Comments
 (0)