Skip to content

Commit 2015e84

Browse files
committed
Added tests for DataFrames
The one with `method=pad` currently fails. The others pass.
1 parent 255518e commit 2015e84

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/tests/frame/test_missing.py

+28
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,34 @@ def test_frame_fillna_limit(self):
549549
expected.values[:3] = np.nan
550550
tm.assert_frame_equal(result, expected)
551551

552+
def test_frame_interp_max_gap(self):
553+
nan = np.nan
554+
s = Series(
555+
[nan, 1.0, nan, 2.0, nan, nan, 5.0, nan, nan, nan, -1.0, nan, nan])
556+
df = pd.concat([s, s], axis=1)
557+
558+
expected_s = Series(
559+
[1.0, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, nan, nan, nan, -1.0, -1, -1]
560+
)
561+
expected_df = pd.concat([expected_s, expected_s], axis=1)
562+
563+
result = df.interpolate(method="linear", max_gap=2)
564+
assert_frame_equal(result, expected_df)
565+
566+
expected_s = Series(
567+
[nan, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, nan, nan, nan, -1.0, nan, nan]
568+
)
569+
expected_df = pd.concat([expected_s, expected_s], axis=1)
570+
result = df.interpolate(method="linear", max_gap=2, limit_area="inside")
571+
assert_frame_equal(result, expected_df)
572+
573+
expected_s = Series(
574+
[nan, 1.0, 1, 2.0, 2.0, 2.0, 5.0, nan, nan, nan, -1.0, nan, nan]
575+
)
576+
expected_df = pd.concat([expected_s, expected_s], axis=1)
577+
result = df.interpolate(method="pad", max_gap=2, limit_area="inside")
578+
assert_frame_equal(result, expected_df)
579+
552580
def test_fillna_skip_certain_blocks(self):
553581
# don't try to fill boolean, int blocks
554582

0 commit comments

Comments
 (0)