@@ -295,22 +295,7 @@ def test_interp_ffill(self, axis):
295295 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
296296 }
297297 )
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- )
298+ expected = df .ffill (axis = axis )
314299 result = df .interpolate (method = "ffill" , axis = axis )
315300 tm .assert_frame_equal (result , expected )
316301
@@ -324,22 +309,7 @@ def test_interp_bfill(self, axis):
324309 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
325310 }
326311 )
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- )
312+ expected = df .bfill (axis = axis )
343313 result = df .interpolate (method = "bfill" , axis = axis )
344314 tm .assert_frame_equal (result , expected )
345315
@@ -353,21 +323,6 @@ def test_interp_pad(self, axis):
353323 "C" : [3.0 , 6.0 , 9.0 , np .nan , np .nan , 30.0 ],
354324 }
355325 )
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- )
326+ expected = df .fillna (method = 'pad' , axis = axis )
372327 result = df .interpolate (method = "pad" , axis = axis )
373328 tm .assert_frame_equal (result , expected )
0 commit comments