Skip to content

Commit d1049bc

Browse files
committed
Avoid recasting a CFTimeIndex
xref pydata#7730
1 parent 4448828 commit d1049bc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xarray/core/indexes.py

Lines changed: 1 addition & 1 deletion
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)