@@ -1177,6 +1177,7 @@ def test_replace_series_datetime_tz(self, how, to_key, from_key, replacer):
1177
1177
assert obj .dtype == from_key
1178
1178
1179
1179
result = obj .replace (replacer )
1180
+
1180
1181
exp = pd .Series (self .rep [to_key ], index = index , name = "yyy" )
1181
1182
assert exp .dtype == to_key
1182
1183
@@ -1197,7 +1198,21 @@ def test_replace_series_datetime_datetime(self, how, to_key, from_key, replacer)
1197
1198
obj = pd .Series (self .rep [from_key ], index = index , name = "yyy" )
1198
1199
assert obj .dtype == from_key
1199
1200
1200
- result = obj .replace (replacer )
1201
+ warn = None
1202
+ rep_ser = pd .Series (replacer )
1203
+ if (
1204
+ isinstance (obj .dtype , pd .DatetimeTZDtype )
1205
+ and isinstance (rep_ser .dtype , pd .DatetimeTZDtype )
1206
+ and obj .dtype != rep_ser .dtype
1207
+ ):
1208
+ # mismatched tz DatetimeArray behavior will change to cast
1209
+ # for setitem-like methods with mismatched tzs
1210
+ warn = FutureWarning
1211
+
1212
+ msg = "explicitly cast to object"
1213
+ with tm .assert_produces_warning (warn , match = msg ):
1214
+ result = obj .replace (replacer )
1215
+
1201
1216
exp = pd .Series (self .rep [to_key ], index = index , name = "yyy" )
1202
1217
assert exp .dtype == to_key
1203
1218
0 commit comments