File tree 4 files changed +28
-1
lines changed
4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1144,6 +1144,7 @@ Conversion
1144
1144
- Bug in ``DataFrame.fillna()`` where the argument ``downcast`` was ignored when fillna value was of type ``dict`` (:issue:`15277`)
1145
1145
- Bug in ``.asfreq()``, where frequency was not set for empty ``Series`` (:issue:`14320`)
1146
1146
- Bug in ``DataFrame`` construction with nulls and datetimes in a list-like (:issue:`15869`)
1147
+ - Bug in ``DataFrame.fillna()`` with tz-aware datetimes (:issue:`15855`)
1147
1148
1148
1149
Indexing
1149
1150
^^^^^^^^
Original file line number Diff line number Diff line change @@ -2475,7 +2475,7 @@ def _try_coerce_result(self, result):
2475
2475
if isinstance (result , np .ndarray ):
2476
2476
# allow passing of > 1dim if its trivial
2477
2477
if result .ndim > 1 :
2478
- result = result .reshape (len (result ))
2478
+ result = result .reshape (np . prod (result . shape ))
2479
2479
result = self .values ._shallow_copy (result )
2480
2480
2481
2481
return result
Original file line number Diff line number Diff line change @@ -257,6 +257,20 @@ def test_fillna(self):
257
257
result = df .fillna (value = {'Date' : df ['Date2' ]})
258
258
assert_frame_equal (result , expected )
259
259
260
+ # with timezone
261
+ # GH 15855
262
+ df = pd .DataFrame ({'A' : [pd .Timestamp ('2012-11-11 00:00:00+01:00' ),
263
+ pd .NaT ]})
264
+ exp = pd .DataFrame ({'A' : [pd .Timestamp ('2012-11-11 00:00:00+01:00' ),
265
+ pd .Timestamp ('2012-11-11 00:00:00+01:00' )]})
266
+ assert_frame_equal (df .fillna (method = 'pad' ), exp )
267
+
268
+ df = pd .DataFrame ({'A' : [pd .NaT ,
269
+ pd .Timestamp ('2012-11-11 00:00:00+01:00' )]})
270
+ exp = pd .DataFrame ({'A' : [pd .Timestamp ('2012-11-11 00:00:00+01:00' ),
271
+ pd .Timestamp ('2012-11-11 00:00:00+01:00' )]})
272
+ assert_frame_equal (df .fillna (method = 'bfill' ), exp )
273
+
260
274
def test_fillna_downcast (self ):
261
275
# GH 15277
262
276
# infer int64 from float64
Original file line number Diff line number Diff line change @@ -258,6 +258,18 @@ def test_datetime64_tz_fillna(self):
258
258
self .assert_series_equal (expected , result )
259
259
self .assert_series_equal (pd .isnull (s ), null_loc )
260
260
261
+ # with timezone
262
+ # GH 15855
263
+ df = pd .Series ([pd .Timestamp ('2012-11-11 00:00:00+01:00' ), pd .NaT ])
264
+ exp = pd .Series ([pd .Timestamp ('2012-11-11 00:00:00+01:00' ),
265
+ pd .Timestamp ('2012-11-11 00:00:00+01:00' )])
266
+ assert_series_equal (df .fillna (method = 'pad' ), exp )
267
+
268
+ df = pd .Series ([pd .NaT , pd .Timestamp ('2012-11-11 00:00:00+01:00' )])
269
+ exp = pd .Series ([pd .Timestamp ('2012-11-11 00:00:00+01:00' ),
270
+ pd .Timestamp ('2012-11-11 00:00:00+01:00' )])
271
+ assert_series_equal (df .fillna (method = 'bfill' ), exp )
272
+
261
273
def test_datetime64tz_fillna_round_issue (self ):
262
274
# GH 14872
263
275
You can’t perform that action at this time.
0 commit comments