@@ -7285,9 +7285,7 @@ def replace(
7285
7285
value = ...,
7286
7286
* ,
7287
7287
inplace : Literal [False ] = ...,
7288
- limit : int | None = ...,
7289
7288
regex : bool = ...,
7290
- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
7291
7289
) -> Self : ...
7292
7290
7293
7291
@overload
@@ -7297,9 +7295,7 @@ def replace(
7297
7295
value = ...,
7298
7296
* ,
7299
7297
inplace : Literal [True ],
7300
- limit : int | None = ...,
7301
7298
regex : bool = ...,
7302
- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
7303
7299
) -> None : ...
7304
7300
7305
7301
@overload
@@ -7309,9 +7305,7 @@ def replace(
7309
7305
value = ...,
7310
7306
* ,
7311
7307
inplace : bool = ...,
7312
- limit : int | None = ...,
7313
7308
regex : bool = ...,
7314
- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = ...,
7315
7309
) -> Self | None : ...
7316
7310
7317
7311
@final
@@ -7326,32 +7320,9 @@ def replace(
7326
7320
value = lib .no_default ,
7327
7321
* ,
7328
7322
inplace : bool = False ,
7329
- limit : int | None = None ,
7330
7323
regex : bool = False ,
7331
- method : Literal ["pad" , "ffill" , "bfill" ] | lib .NoDefault = lib .no_default ,
7332
7324
) -> 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 :
7355
7326
# case that goes through _replace_single and defaults to method="pad"
7356
7327
warnings .warn (
7357
7328
# GH#33302
@@ -7387,14 +7358,11 @@ def replace(
7387
7358
if not is_bool (regex ) and to_replace is not None :
7388
7359
raise ValueError ("'to_replace' must be 'None' if 'regex' is not a bool" )
7389
7360
7390
- if value is lib .no_default or method is not lib . no_default :
7361
+ if value is lib .no_default :
7391
7362
# GH#36984 if the user explicitly passes value=None we want to
7392
7363
# respect that. We have the corner case where the user explicitly
7393
7364
# passes value=None *and* a method, which we interpret as meaning
7394
7365
# 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"
7398
7366
7399
7367
# passing a single value that is scalar like
7400
7368
# when value is None (GH5319), for compat
@@ -7408,12 +7376,12 @@ def replace(
7408
7376
7409
7377
result = self .apply (
7410
7378
Series ._replace_single ,
7411
- args = (to_replace , method , inplace , limit ),
7379
+ args = (to_replace , inplace ),
7412
7380
)
7413
7381
if inplace :
7414
7382
return None
7415
7383
return result
7416
- return self ._replace_single (to_replace , method , inplace , limit )
7384
+ return self ._replace_single (to_replace , inplace )
7417
7385
7418
7386
if not is_dict_like (to_replace ):
7419
7387
if not is_dict_like (regex ):
@@ -7458,9 +7426,7 @@ def replace(
7458
7426
else :
7459
7427
to_replace , value = keys , values
7460
7428
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 )
7464
7430
else :
7465
7431
# need a non-zero len on all axes
7466
7432
if not self .size :
@@ -7524,9 +7490,7 @@ def replace(
7524
7490
f"or a list or dict of strings or regular expressions, "
7525
7491
f"you passed a { type (regex ).__name__ !r} "
7526
7492
)
7527
- return self .replace (
7528
- regex , value , inplace = inplace , limit = limit , regex = True
7529
- )
7493
+ return self .replace (regex , value , inplace = inplace , regex = True )
7530
7494
else :
7531
7495
# dest iterable dict-like
7532
7496
if is_dict_like (value ): # NA -> {'A' : 0, 'B' : -1}
0 commit comments