Skip to content

Commit 2081a03

Browse files
committed
add back missed try block
1 parent 4d0c9b5 commit 2081a03

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/indexes/period.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,10 @@ def shift(self, periods: int = 1, freq=None) -> Self:
516516

517517
def _difference(self, other, sort=None) -> PeriodIndex:
518518
if isinstance(other, Index) and other.inferred_type == "string":
519-
other = other.astype(self.dtype)
519+
try:
520+
other = other.astype(self.dtype)
521+
except (TypeError, ValueError):
522+
pass
520523

521524
return super()._difference(other, sort=sort)
522525

0 commit comments

Comments
 (0)