@@ -273,6 +273,40 @@ def test_datetime64_tz_fillna(self):
273
273
pd .Timestamp ('2012-11-11 00:00:00+01:00' )])
274
274
assert_series_equal (df .fillna (method = 'bfill' ), exp )
275
275
276
+ def test_fillna_consistency (self ):
277
+ # GH 16402
278
+ # fillna with a tz aware to a tz-naive, should result in object
279
+
280
+ s = Series ([Timestamp ('20130101' ), pd .NaT ])
281
+
282
+ result = s .fillna (Timestamp ('20130101' , tz = 'US/Eastern' ))
283
+ expected = Series ([Timestamp ('20130101' ),
284
+ Timestamp ('2013-01-01' , tz = 'US/Eastern' )],
285
+ dtype = 'object' )
286
+ assert_series_equal (result , expected )
287
+
288
+ # where (we ignore the raise_on_error)
289
+ result = s .where ([True , False ],
290
+ Timestamp ('20130101' , tz = 'US/Eastern' ),
291
+ raise_on_error = False )
292
+ assert_series_equal (result , expected )
293
+
294
+ result = s .where ([True , False ],
295
+ Timestamp ('20130101' , tz = 'US/Eastern' ),
296
+ raise_on_error = True )
297
+ assert_series_equal (result , expected )
298
+
299
+ # with a non-datetime
300
+ result = s .fillna ('foo' )
301
+ expected = Series ([Timestamp ('20130101' ),
302
+ 'foo' ])
303
+ assert_series_equal (result , expected )
304
+
305
+ # assignment
306
+ s2 = s .copy ()
307
+ s2 [1 ] = 'foo'
308
+ assert_series_equal (s2 , expected )
309
+
276
310
def test_datetime64tz_fillna_round_issue (self ):
277
311
# GH 14872
278
312
0 commit comments