@@ -195,6 +195,37 @@ def test_fillna_preserves_tz(self, method):
195
195
assert arr [2 ] is pd .NaT
196
196
assert dti [2 ] == pd .Timestamp ("2000-01-03" , tz = "US/Central" )
197
197
198
+ def test_fillna_2d (self ):
199
+ dti = pd .date_range ("2016-01-01" , periods = 6 , tz = "US/Pacific" )
200
+ dta = dti ._data .reshape (3 , 2 ).copy ()
201
+ dta [0 , 1 ] = pd .NaT
202
+ dta [1 , 0 ] = pd .NaT
203
+
204
+ res1 = dta .fillna (method = "pad" )
205
+ expected1 = dta .copy ()
206
+ expected1 [1 , 0 ] = dta [0 , 0 ]
207
+ tm .assert_extension_array_equal (res1 , expected1 )
208
+
209
+ res2 = dta .fillna (method = "backfill" )
210
+ expected2 = dta .copy ()
211
+ expected2 = dta .copy ()
212
+ expected2 [1 , 0 ] = dta [2 , 0 ]
213
+ expected2 [0 , 1 ] = dta [1 , 1 ]
214
+ tm .assert_extension_array_equal (res2 , expected2 )
215
+
216
+ # with different ordering for underlying ndarray; behavior should
217
+ # be unchanged
218
+ dta2 = dta ._from_backing_data (dta ._ndarray .copy (order = "F" ))
219
+ assert dta2 ._ndarray .flags ["F_CONTIGUOUS" ]
220
+ assert not dta2 ._ndarray .flags ["C_CONTIGUOUS" ]
221
+ tm .assert_extension_array_equal (dta , dta2 )
222
+
223
+ res3 = dta2 .fillna (method = "pad" )
224
+ tm .assert_extension_array_equal (res3 , expected1 )
225
+
226
+ res4 = dta2 .fillna (method = "backfill" )
227
+ tm .assert_extension_array_equal (res4 , expected2 )
228
+
198
229
def test_array_interface_tz (self ):
199
230
tz = "US/Central"
200
231
data = DatetimeArray (pd .date_range ("2017" , periods = 2 , tz = tz ))
0 commit comments