@@ -6891,7 +6891,7 @@ def _deprecate_downcast(self, downcast) -> None:
68916891 )
68926892
68936893 @final
6894- def _fillna_with_method (
6894+ def _pad_or_backfill (
68956895 self ,
68966896 method : Literal ["ffill" , "bfill" , "pad" , "backfill" ],
68976897 * ,
@@ -6908,7 +6908,7 @@ def _fillna_with_method(
69086908 if not self ._mgr .is_single_block and axis == 1 :
69096909 if inplace :
69106910 raise NotImplementedError ()
6911- result = self .T ._fillna_with_method (method = method , limit = limit ).T
6911+ result = self .T ._pad_or_backfill (method = method , limit = limit ).T
69126912
69136913 return result
69146914
@@ -7105,8 +7105,8 @@ def fillna(
71057105 axis = self ._get_axis_number (axis )
71067106
71077107 if value is None :
7108- return self ._fillna_with_method (
7109- # error: Argument 1 to "_fillna_with_method " of "NDFrame" has
7108+ return self ._pad_or_backfill (
7109+ # error: Argument 1 to "_pad_or_backfill " of "NDFrame" has
71107110 # incompatible type "Optional[Literal['backfill', 'bfill', 'ffill',
71117111 # 'pad']]"; expected "Literal['ffill', 'bfill', 'pad', 'backfill']"
71127112 method , # type: ignore[arg-type]
@@ -7311,7 +7311,7 @@ def ffill(
73117311 """
73127312 self ._deprecate_downcast (downcast )
73137313
7314- return self ._fillna_with_method (
7314+ return self ._pad_or_backfill (
73157315 "ffill" , axis = axis , inplace = inplace , limit = limit , downcast = downcast
73167316 )
73177317
@@ -7443,7 +7443,7 @@ def bfill(
74437443 3 4.0 7
74447444 """
74457445 self ._deprecate_downcast (downcast )
7446- return self ._fillna_with_method (
7446+ return self ._pad_or_backfill (
74477447 "bfill" , axis = axis , inplace = inplace , limit = limit , downcast = downcast
74487448 )
74497449
@@ -8003,22 +8003,27 @@ def interpolate(
80038003 "column to a numeric dtype."
80048004 )
80058005
8006- index = missing .get_interp_index (method , obj .index )
8006+ if "fill_value" in kwargs :
8007+ raise ValueError (
8008+ "'fill_value' is not a valid keyword for "
8009+ f"{ type (self ).__name__ } .interpolate"
8010+ )
80078011
80088012 if method .lower () in fillna_methods :
80098013 # TODO(3.0): remove this case
8014+ # TODO: warn/raise on limit_direction or kwargs which are ignored?
8015+ # as of 2023-06-26 no tests get here with either
8016+
80108017 new_data = obj ._mgr .pad_or_backfill (
80118018 method = method ,
80128019 axis = axis ,
8013- index = index ,
80148020 limit = limit ,
8015- limit_direction = limit_direction ,
80168021 limit_area = limit_area ,
80178022 inplace = inplace ,
80188023 downcast = downcast ,
8019- ** kwargs ,
80208024 )
80218025 else :
8026+ index = missing .get_interp_index (method , obj .index )
80228027 axis = self ._info_axis_number
80238028 new_data = obj ._mgr .interpolate (
80248029 method = method ,
@@ -9980,8 +9985,8 @@ def _align_frame(
99809985 )
99819986
99829987 if method is not None :
9983- left = left ._fillna_with_method (method , axis = fill_axis , limit = limit )
9984- right = right ._fillna_with_method (method , axis = fill_axis , limit = limit )
9988+ left = left ._pad_or_backfill (method , axis = fill_axis , limit = limit )
9989+ right = right ._pad_or_backfill (method , axis = fill_axis , limit = limit )
99859990
99869991 return left , right , join_index
99879992
@@ -10057,8 +10062,8 @@ def _align_series(
1005710062 if fill_na :
1005810063 fill_value , method = validate_fillna_kwargs (fill_value , method )
1005910064 if method is not None :
10060- left = left ._fillna_with_method (method , limit = limit , axis = fill_axis )
10061- right = right ._fillna_with_method (method , limit = limit )
10065+ left = left ._pad_or_backfill (method , limit = limit , axis = fill_axis )
10066+ right = right ._pad_or_backfill (method , limit = limit )
1006210067 else :
1006310068 left = left .fillna (fill_value , limit = limit , axis = fill_axis )
1006410069 right = right .fillna (fill_value , limit = limit )
@@ -11474,7 +11479,7 @@ def pct_change(
1147411479 if fill_method is None :
1147511480 data = self
1147611481 else :
11477- data = self ._fillna_with_method (fill_method , axis = axis , limit = limit )
11482+ data = self ._pad_or_backfill (fill_method , axis = axis , limit = limit )
1147811483
1147911484 shifted = data .shift (periods = periods , freq = freq , axis = axis , ** kwargs )
1148011485 # Unsupported left operand type for / ("Self")
0 commit comments