@@ -7285,9 +7285,7 @@ def replace(
72857285 value = ...,
72867286 * ,
72877287 inplace : Literal [False ] = ...,
7288- limit : int | None = ...,
72897288 regex : bool = ...,
7290- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
72917289 ) -> Self : ...
72927290
72937291 @overload
@@ -7297,9 +7295,7 @@ def replace(
72977295 value = ...,
72987296 * ,
72997297 inplace : Literal [True ],
7300- limit : int | None = ...,
73017298 regex : bool = ...,
7302- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
73037299 ) -> None : ...
73047300
73057301 @overload
@@ -7309,9 +7305,7 @@ def replace(
73097305 value = ...,
73107306 * ,
73117307 inplace : bool = ...,
7312- limit : int | None = ...,
73137308 regex : bool = ...,
7314- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
73157309 ) -> Self | None : ...
73167310
73177311 @final
@@ -7326,32 +7320,9 @@ def replace(
73267320 value = lib .no_default ,
73277321 * ,
73287322 inplace : bool = False ,
7329- limit : int | None = None ,
73307323 regex : bool = False ,
7331- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = lib .no_default ,
73327324 ) -> Self | None :
7333- if method is not lib .no_default :
7334- warnings .warn (
7335- # GH#33302
7336- f"The 'method' keyword in { type (self ).__name__ } .replace is "
7337- "deprecated and will be removed in a future version." ,
7338- FutureWarning ,
7339- stacklevel = find_stack_level (),
7340- )
7341- elif limit is not None :
7342- warnings .warn (
7343- # GH#33302
7344- f"The 'limit' keyword in { type (self ).__name__ } .replace is "
7345- "deprecated and will be removed in a future version." ,
7346- FutureWarning ,
7347- stacklevel = find_stack_level (),
7348- )
7349- if (
7350- value is lib .no_default
7351- and method is lib .no_default
7352- and not is_dict_like (to_replace )
7353- and regex is False
7354- ):
7325+ if value is lib .no_default and not is_dict_like (to_replace ) and regex is False :
73557326 # case that goes through _replace_single and defaults to method="pad"
73567327 warnings .warn (
73577328 # GH#33302
@@ -7387,14 +7358,11 @@ def replace(
73877358 if not is_bool (regex ) and to_replace is not None :
73887359 raise ValueError ("'to_replace' must be 'None' if 'regex' is not a bool" )
73897360
7390- if value is lib .no_default or method is not lib . no_default :
7361+ if value is lib .no_default :
73917362 # GH#36984 if the user explicitly passes value=None we want to
73927363 # respect that. We have the corner case where the user explicitly
73937364 # passes value=None *and* a method, which we interpret as meaning
73947365 # they want the (documented) default behavior.
7395- if method is lib .no_default :
7396- # TODO: get this to show up as the default in the docs?
7397- method = "pad"
73987366
73997367 # passing a single value that is scalar like
74007368 # when value is None (GH5319), for compat
@@ -7408,12 +7376,12 @@ def replace(
74087376
74097377 result = self .apply (
74107378 Series ._replace_single ,
7411- args = (to_replace , method , inplace , limit ),
7379+ args = (to_replace , inplace ),
74127380 )
74137381 if inplace :
74147382 return None
74157383 return result
7416- return self ._replace_single (to_replace , method , inplace , limit )
7384+ return self ._replace_single (to_replace , inplace )
74177385
74187386 if not is_dict_like (to_replace ):
74197387 if not is_dict_like (regex ):
@@ -7458,9 +7426,7 @@ def replace(
74587426 else :
74597427 to_replace , value = keys , values
74607428
7461- return self .replace (
7462- to_replace , value , inplace = inplace , limit = limit , regex = regex
7463- )
7429+ return self .replace (to_replace , value , inplace = inplace , regex = regex )
74647430 else :
74657431 # need a non-zero len on all axes
74667432 if not self .size :
@@ -7524,9 +7490,7 @@ def replace(
75247490 f"or a list or dict of strings or regular expressions, "
75257491 f"you passed a { type (regex ).__name__ !r} "
75267492 )
7527- return self .replace (
7528- regex , value , inplace = inplace , limit = limit , regex = True
7529- )
7493+ return self .replace (regex , value , inplace = inplace , regex = True )
75307494 else :
75317495 # dest iterable dict-like
75327496 if is_dict_like (value ): # NA -> {'A' : 0, 'B' : -1}
0 commit comments