@@ -549,6 +549,34 @@ def test_frame_fillna_limit(self):
549
549
expected .values [:3 ] = np .nan
550
550
tm .assert_frame_equal (result , expected )
551
551
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
+
552
580
def test_fillna_skip_certain_blocks (self ):
553
581
# don't try to fill boolean, int blocks
554
582
0 commit comments