Skip to content

Commit 8ae8a06

Browse files
committed
Cast self before tz check in _get_arithmetic_result_freq
1 parent 47cd7e8 commit 8ae8a06

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,16 @@ def _get_arithmetic_result_freq(self, other) -> BaseOffset | None:
10931093
lib.is_np_dtype(self.dtype, "M")
10941094
and isinstance(self.freq, Day)
10951095
and isinstance(other, Timestamp)
1096-
and (self.tz is None or timezones.is_utc(self.tz))
1097-
and (other.tz is None or timezones.is_utc(other.tz))
10981096
):
1099-
# e.g. issue gh-62094: subtracting a Timestamp from a DTI
1100-
# with Day freq retains that freq
1101-
return self.freq
1097+
self = cast("DatetimeArray", self)
1098+
if (
1099+
self.tz is None or timezones.is_utc(self.tz)
1100+
) and (
1101+
other.tz is None or timezones.is_utc(other.tz)
1102+
):
1103+
# e.g. issue gh-62094: subtracting a Timestamp from a DTI
1104+
# with Day freq retains that freq
1105+
return self.freq
11021106

11031107
return None
11041108

0 commit comments

Comments
 (0)