Skip to content

Commit 7c5ad7d

Browse files
committed
Added tests back in
Tests should be red now
1 parent 8ceff58 commit 7c5ad7d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

pandas/tests/series/methods/test_interpolate.py

+54
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,60 @@ def test_interp_limit_direction_raises(self, method, limit_direction, expected):
450450
with pytest.raises(ValueError, match=msg):
451451
s.interpolate(method=method, limit_direction=limit_direction)
452452

453+
def test_interp_limit_area_with_pad(self):
454+
# Test for issue #26796
455+
s = Series(
456+
[np.nan, np.nan, 3, np.nan, np.nan, np.nan, 7, np.nan, np.nan])
457+
458+
expected = Series(
459+
[np.nan, np.nan, 3.0, 3.0, 3.0, 3.0, 7.0, np.nan, np.nan])
460+
result = s.interpolate(method="pad", limit_area="inside")
461+
tm.assert_series_equal(result, expected)
462+
463+
expected = Series(
464+
[np.nan, np.nan, 3.0, 3.0, np.nan, np.nan, 7.0, np.nan, np.nan]
465+
)
466+
result = s.interpolate(method="pad", limit_area="inside", limit=1)
467+
tm.assert_series_equal(result, expected)
468+
469+
expected = Series(
470+
[np.nan, np.nan, 3.0, np.nan, np.nan, np.nan, 7.0, 7.0, 7.0])
471+
result = s.interpolate(method="pad", limit_area="outside")
472+
tm.assert_series_equal(result, expected)
473+
474+
expected = Series(
475+
[np.nan, np.nan, 3.0, np.nan, np.nan, np.nan, 7.0, 7.0, np.nan]
476+
)
477+
result = s.interpolate(method="pad", limit_area="outside", limit=1)
478+
tm.assert_series_equal(result, expected)
479+
480+
def test_interp_limit_area_with_backfill(self):
481+
# Test for issue #26796
482+
s = Series(
483+
[np.nan, np.nan, 3, np.nan, np.nan, np.nan, 7, np.nan, np.nan])
484+
485+
expected = Series(
486+
[np.nan, np.nan, 3.0, 7.0, 7.0, 7.0, 7.0, np.nan, np.nan])
487+
result = s.interpolate(method="bfill", limit_area="inside")
488+
tm.assert_series_equal(result, expected)
489+
490+
expected = Series(
491+
[np.nan, np.nan, 3.0, np.nan, np.nan, 7.0, 7.0, np.nan, np.nan]
492+
)
493+
result = s.interpolate(method="bfill", limit_area="inside", limit=1)
494+
tm.assert_series_equal(result, expected)
495+
496+
expected = Series(
497+
[3.0, 3.0, 3.0, np.nan, np.nan, np.nan, 7.0, np.nan, np.nan])
498+
result = s.interpolate(method="bfill", limit_area="outside")
499+
tm.assert_series_equal(result, expected)
500+
501+
expected = Series(
502+
[np.nan, 3.0, 3.0, np.nan, np.nan, np.nan, 7.0, np.nan, np.nan]
503+
)
504+
result = s.interpolate(method="bfill", limit_area="outside", limit=1)
505+
tm.assert_series_equal(result, expected)
506+
453507
def test_interp_limit_direction(self):
454508
# These tests are for issue #9218 -- fill NaNs in both directions.
455509
s = Series([1, 3, np.nan, np.nan, np.nan, 11])

0 commit comments

Comments
 (0)