@@ -6891,7 +6891,7 @@ def _deprecate_downcast(self, downcast) -> None:
6891
6891
)
6892
6892
6893
6893
@final
6894
- def _fillna_with_method (
6894
+ def _pad_or_backfill (
6895
6895
self ,
6896
6896
method : Literal ["ffill" , "bfill" , "pad" , "backfill" ],
6897
6897
* ,
@@ -6908,7 +6908,7 @@ def _fillna_with_method(
6908
6908
if not self ._mgr .is_single_block and axis == 1 :
6909
6909
if inplace :
6910
6910
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
6912
6912
6913
6913
return result
6914
6914
@@ -7105,8 +7105,8 @@ def fillna(
7105
7105
axis = self ._get_axis_number (axis )
7106
7106
7107
7107
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
7110
7110
# incompatible type "Optional[Literal['backfill', 'bfill', 'ffill',
7111
7111
# 'pad']]"; expected "Literal['ffill', 'bfill', 'pad', 'backfill']"
7112
7112
method , # type: ignore[arg-type]
@@ -7311,7 +7311,7 @@ def ffill(
7311
7311
"""
7312
7312
self ._deprecate_downcast (downcast )
7313
7313
7314
- return self ._fillna_with_method (
7314
+ return self ._pad_or_backfill (
7315
7315
"ffill" , axis = axis , inplace = inplace , limit = limit , downcast = downcast
7316
7316
)
7317
7317
@@ -7443,7 +7443,7 @@ def bfill(
7443
7443
3 4.0 7
7444
7444
"""
7445
7445
self ._deprecate_downcast (downcast )
7446
- return self ._fillna_with_method (
7446
+ return self ._pad_or_backfill (
7447
7447
"bfill" , axis = axis , inplace = inplace , limit = limit , downcast = downcast
7448
7448
)
7449
7449
@@ -8003,22 +8003,27 @@ def interpolate(
8003
8003
"column to a numeric dtype."
8004
8004
)
8005
8005
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
+ )
8007
8011
8008
8012
if method .lower () in fillna_methods :
8009
8013
# 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
+
8010
8017
new_data = obj ._mgr .pad_or_backfill (
8011
8018
method = method ,
8012
8019
axis = axis ,
8013
- index = index ,
8014
8020
limit = limit ,
8015
- limit_direction = limit_direction ,
8016
8021
limit_area = limit_area ,
8017
8022
inplace = inplace ,
8018
8023
downcast = downcast ,
8019
- ** kwargs ,
8020
8024
)
8021
8025
else :
8026
+ index = missing .get_interp_index (method , obj .index )
8022
8027
axis = self ._info_axis_number
8023
8028
new_data = obj ._mgr .interpolate (
8024
8029
method = method ,
@@ -9980,8 +9985,8 @@ def _align_frame(
9980
9985
)
9981
9986
9982
9987
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 )
9985
9990
9986
9991
return left , right , join_index
9987
9992
@@ -10057,8 +10062,8 @@ def _align_series(
10057
10062
if fill_na :
10058
10063
fill_value , method = validate_fillna_kwargs (fill_value , method )
10059
10064
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 )
10062
10067
else :
10063
10068
left = left .fillna (fill_value , limit = limit , axis = fill_axis )
10064
10069
right = right .fillna (fill_value , limit = limit )
@@ -11474,7 +11479,7 @@ def pct_change(
11474
11479
if fill_method is None :
11475
11480
data = self
11476
11481
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 )
11478
11483
11479
11484
shifted = data .shift (periods = periods , freq = freq , axis = axis , ** kwargs )
11480
11485
# Unsupported left operand type for / ("Self")
0 commit comments