Skip to content

Commit

Permalink
Avoid recasting a CFTimeIndex (#7735)
Browse files Browse the repository at this point in the history
xref #7730
  • Loading branch information
dcherian authored Apr 11, 2023
1 parent a1f5245 commit c3224ef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xarray/core/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _repr_inline_(self, max_width):
def _maybe_cast_to_cftimeindex(index: pd.Index) -> pd.Index:
from xarray.coding.cftimeindex import CFTimeIndex

if len(index) > 0 and index.dtype == "O":
if len(index) > 0 and index.dtype == "O" and not isinstance(index, CFTimeIndex):
try:
return CFTimeIndex(index)
except (ImportError, TypeError):
Expand Down

0 comments on commit c3224ef

Please sign in to comment.