Skip to content

Commit 4f3bcbc

Browse files
committed
add tests
1 parent 5ef4eba commit 4f3bcbc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pandas/tests/frame/methods/test_interpolate.py

+42
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,45 @@ def test_interp_time_inplace_axis(self, axis):
286286
expected.interpolate(axis=0, method="time", inplace=True)
287287
tm.assert_frame_equal(result, expected)
288288

289+
290+
@pytest.mark.parametrize("axis", [0, 1])
291+
def test_interp_ffill(self, axis):
292+
# GH 33956
293+
df = DataFrame(
294+
{
295+
"A": [1.0, 2.0, 3.0, 4.0, np.nan, 5.0],
296+
"B": [2.0, 4.0, 6.0, np.nan, 8.0, 10.0],
297+
"C": [3.0, 6.0, 9.0, np.nan, np.nan, 30.0],
298+
}
299+
)
300+
expected = df.ffill(axis=axis)
301+
result = df.interpolate(method="ffill", axis=axis)
302+
tm.assert_frame_equal(result, expected)
303+
304+
@pytest.mark.parametrize("axis", [0, 1])
305+
def test_interp_bfill(self, axis):
306+
# GH 33956
307+
df = DataFrame(
308+
{
309+
"A": [1.0, 2.0, 3.0, 4.0, np.nan, 5.0],
310+
"B": [2.0, 4.0, 6.0, np.nan, 8.0, 10.0],
311+
"C": [3.0, 6.0, 9.0, np.nan, np.nan, 30.0],
312+
}
313+
)
314+
expected = df.bfill(axis=axis)
315+
result = df.interpolate(method="bfill", axis=axis)
316+
tm.assert_frame_equal(result, expected)
317+
318+
@pytest.mark.parametrize("axis", [0, 1])
319+
def test_interp_pad(self, axis):
320+
# GH 33956
321+
df = DataFrame(
322+
{
323+
"A": [1.0, 2.0, 3.0, 4.0, np.nan, 5.0],
324+
"B": [2.0, 4.0, 6.0, np.nan, 8.0, 10.0],
325+
"C": [3.0, 6.0, 9.0, np.nan, np.nan, 30.0],
326+
}
327+
)
328+
expected = df.fillna(method='pad', axis=axis)
329+
result = df.interpolate(method="pad", axis=axis)
330+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)