diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 761f5df3bb4e0..a1bfe11becdad 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -7017,7 +7017,11 @@ def diff(self, periods: int = 1) -> Self: Index([nan, 10.0, 10.0, 10.0, 10.0], dtype='float64') """ - return self._constructor(self.to_series().diff(periods)) + diff = self.to_series().diff(periods) + if diff.dtype != self.dtype: + # e.g. DTI.diff -> TDI + return Index(diff) + return self._constructor(diff) @final def round(self, decimals: int = 0) -> Self: