38
38
from pandas .util ._exceptions import find_stack_level
39
39
from pandas .util ._validators import (
40
40
validate_bool_kwarg ,
41
- validate_fillna_kwargs ,
42
41
validate_insert_loc ,
43
42
)
44
43
@@ -1007,31 +1006,6 @@ def _pad_or_backfill(
1007
1006
[<NA>, 2, 2, 3, <NA>, <NA>]
1008
1007
Length: 6, dtype: Int64
1009
1008
"""
1010
-
1011
- # If a 3rd-party EA has implemented this functionality in fillna,
1012
- # we warn that they need to implement _pad_or_backfill instead.
1013
- if (
1014
- type (self ).fillna is not ExtensionArray .fillna
1015
- and type (self )._pad_or_backfill is ExtensionArray ._pad_or_backfill
1016
- ):
1017
- # Check for _pad_or_backfill here allows us to call
1018
- # super()._pad_or_backfill without getting this warning
1019
- warnings .warn (
1020
- "ExtensionArray.fillna 'method' keyword is deprecated. "
1021
- "In a future version. arr._pad_or_backfill will be called "
1022
- "instead. 3rd-party ExtensionArray authors need to implement "
1023
- "_pad_or_backfill." ,
1024
- DeprecationWarning ,
1025
- stacklevel = find_stack_level (),
1026
- )
1027
- if limit_area is not None :
1028
- raise NotImplementedError (
1029
- f"{ type (self ).__name__ } does not implement limit_area "
1030
- "(added in pandas 2.2). 3rd-party ExtnsionArray authors "
1031
- "need to add this argument to _pad_or_backfill."
1032
- )
1033
- return self .fillna (method = method , limit = limit )
1034
-
1035
1009
mask = self .isna ()
1036
1010
1037
1011
if mask .any ():
@@ -1057,8 +1031,7 @@ def _pad_or_backfill(
1057
1031
1058
1032
def fillna (
1059
1033
self ,
1060
- value : object | ArrayLike | None = None ,
1061
- method : FillnaOptions | None = None ,
1034
+ value : object | ArrayLike ,
1062
1035
limit : int | None = None ,
1063
1036
copy : bool = True ,
1064
1037
) -> Self :
@@ -1071,24 +1044,13 @@ def fillna(
1071
1044
If a scalar value is passed it is used to fill all missing values.
1072
1045
Alternatively, an array-like "value" can be given. It's expected
1073
1046
that the array-like have the same length as 'self'.
1074
- method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
1075
- Method to use for filling holes in reindexed Series:
1076
-
1077
- * pad / ffill: propagate last valid observation forward to next valid.
1078
- * backfill / bfill: use NEXT valid observation to fill gap.
1079
-
1080
- .. deprecated:: 2.1.0
1081
-
1082
1047
limit : int, default None
1083
1048
If method is specified, this is the maximum number of consecutive
1084
1049
NaN values to forward/backward fill. In other words, if there is
1085
1050
a gap with more than this number of consecutive NaNs, it will only
1086
1051
be partially filled. If method is not specified, this is the
1087
1052
maximum number of entries along the entire axis where NaNs will be
1088
1053
filled.
1089
-
1090
- .. deprecated:: 2.1.0
1091
-
1092
1054
copy : bool, default True
1093
1055
Whether to make a copy of the data before filling. If False, then
1094
1056
the original should be modified and no new memory should be allocated.
@@ -1110,16 +1072,6 @@ def fillna(
1110
1072
[0, 0, 2, 3, 0, 0]
1111
1073
Length: 6, dtype: Int64
1112
1074
"""
1113
- if method is not None :
1114
- warnings .warn (
1115
- f"The 'method' keyword in { type (self ).__name__ } .fillna is "
1116
- "deprecated and will be removed in a future version." ,
1117
- FutureWarning ,
1118
- stacklevel = find_stack_level (),
1119
- )
1120
-
1121
- value , method = validate_fillna_kwargs (value , method )
1122
-
1123
1075
mask = self .isna ()
1124
1076
# error: Argument 2 to "check_value_size" has incompatible type
1125
1077
# "ExtensionArray"; expected "ndarray"
@@ -1130,24 +1082,12 @@ def fillna(
1130
1082
)
1131
1083
1132
1084
if mask .any ():
1133
- if method is not None :
1134
- meth = missing .clean_fill_method (method )
1135
-
1136
- npmask = np .asarray (mask )
1137
- if meth == "pad" :
1138
- indexer = libalgos .get_fill_indexer (npmask , limit = limit )
1139
- return self .take (indexer , allow_fill = True )
1140
- else :
1141
- # i.e. meth == "backfill"
1142
- indexer = libalgos .get_fill_indexer (npmask [::- 1 ], limit = limit )[::- 1 ]
1143
- return self [::- 1 ].take (indexer , allow_fill = True )
1085
+ # fill with value
1086
+ if not copy :
1087
+ new_values = self [:]
1144
1088
else :
1145
- # fill with value
1146
- if not copy :
1147
- new_values = self [:]
1148
- else :
1149
- new_values = self .copy ()
1150
- new_values [mask ] = value
1089
+ new_values = self .copy ()
1090
+ new_values [mask ] = value
1151
1091
else :
1152
1092
if not copy :
1153
1093
new_values = self [:]
0 commit comments