@@ -295,7 +295,22 @@ def test_interp_ffill(self, axis):
295295 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
296296 }
297297 )
298- expected = df .ffill (axis = axis )
298+ if axis == 0 :
299+ expected = DataFrame (
300+ {
301+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , np .nan , 5.0 ],
302+ "B" : [2.0 , 4.0 , 6.0 , 4.0 , 8.0 , 10.0 ],
303+ "C" : [3.0 , 6.0 , 9.0 , 4.0 , 8.0 , 30.0 ],
304+ }
305+ )
306+ if axis == 1 :
307+ expected = DataFrame (
308+ {
309+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , 4.0 , 5.0 ],
310+ "B" : [2.0 , 4.0 , 6.0 , 6.0 , 8.0 , 10.0 ],
311+ "C" : [3.0 , 6.0 , 9.0 , 9.0 , 9.0 , 30.0 ],
312+ }
313+ )
299314 result = df .interpolate (method = "ffill" , axis = axis )
300315 tm .assert_frame_equal (result , expected )
301316
@@ -309,7 +324,22 @@ def test_interp_bfill(self, axis):
309324 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
310325 }
311326 )
312- expected = df .bfill (axis = axis )
327+ if axis == 0 :
328+ expected = DataFrame (
329+ {
330+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , 8.0 , 5.0 ],
331+ "B" : [2.0 , 4.0 , 6.0 , np .nan , 8.0 , 10.0 ],
332+ "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
333+ }
334+ )
335+ if axis == 1 :
336+ expected = DataFrame (
337+ {
338+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 5.0 ],
339+ "B" : [2.0 , 4.0 , 6.0 , 8.0 , 8.0 , 10.0 ],
340+ "C" : [3.0 , 6.0 , 9.0 , 30.0 , 30.0 , 30.0 ],
341+ }
342+ )
313343 result = df .interpolate (method = "bfill" , axis = axis )
314344 tm .assert_frame_equal (result , expected )
315345
@@ -323,6 +353,21 @@ def test_interp_pad(self, axis):
323353 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
324354 }
325355 )
326- expected = df .fillna (method = 'pad' , axis = axis )
356+ if axis == 0 :
357+ expected = DataFrame (
358+ {
359+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , np .nan , 5.0 ],
360+ "B" : [2.0 , 4.0 , 6.0 , 4.0 , 8.0 , 10.0 ],
361+ "C" : [3.0 , 6.0 , 9.0 , 4.0 , 8.0 , 30.0 ],
362+ }
363+ )
364+ if axis == 1 :
365+ expected = DataFrame (
366+ {
367+ "A" : [1.0 , 2.0 , 3.0 , 4.0 , 4.0 , 5.0 ],
368+ "B" : [2.0 , 4.0 , 6.0 , 6.0 , 8.0 , 10.0 ],
369+ "C" : [3.0 , 6.0 , 9.0 , 9.0 , 9.0 , 30.0 ],
370+ }
371+ )
327372 result = df .interpolate (method = "pad" , axis = axis )
328373 tm .assert_frame_equal (result , expected )
0 commit comments