@@ -3481,9 +3481,9 @@ def bfill(self, axis=0, inplace=False, limit=None):
3481
3481
return self .fillna (method = 'bfill' , axis = axis , inplace = inplace ,
3482
3482
limit = limit )
3483
3483
3484
- def replace (self , to_replace = None , value = None , method = 'pad' , axis = 0 ,
3485
- inplace = False , limit = None , regex = False , infer_types = False ):
3486
- """Replace values given in 'to_replace' with 'value' or using 'method' .
3484
+ def replace (self , to_replace = None , value = None , inplace = False , limit = None ,
3485
+ regex = False , infer_types = False , method = None , axis = None ):
3486
+ """Replace values given in 'to_replace' with 'value'.
3487
3487
3488
3488
Parameters
3489
3489
----------
@@ -3521,13 +3521,6 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3521
3521
specifying which value to use for each column (columns not in the
3522
3522
dict will not be filled). Regular expressions, strings and lists or
3523
3523
dicts of such objects are also allowed.
3524
- method : {'backfill', 'bfill', 'pad', 'ffill', None}, default 'pad'
3525
- Method to use for filling holes in reindexed Series
3526
- pad / ffill: propagate last valid observation forward to next valid
3527
- backfill / bfill: use NEXT valid observation to fill gap
3528
- axis : {0, 1}, default 0
3529
- 0: fill column-by-column
3530
- 1: fill row-by-row
3531
3524
inplace : boolean, default False
3532
3525
If True, fill the DataFrame in place. Note: this will modify any
3533
3526
other views on this DataFrame, like if you took a no-copy slice of
@@ -3580,10 +3573,17 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3580
3573
if not isinstance (regex , bool ) and to_replace is not None :
3581
3574
raise AssertionError ("'to_replace' must be 'None' if 'regex' is "
3582
3575
"not a bool" )
3583
- self ._consolidate_inplace ()
3576
+ if method is not None :
3577
+ from warnings import warn
3578
+ warn ('the "method" argument is deprecated and will be removed in'
3579
+ 'v0.12; this argument has no effect' )
3584
3580
3585
- axis = self ._get_axis_number (axis )
3586
- method = com ._clean_fill_method (method )
3581
+ if axis is not None :
3582
+ from warnings import warn
3583
+ warn ('the "axis" argument is deprecated and will be removed in'
3584
+ 'v0.12; this argument has no effect' )
3585
+
3586
+ self ._consolidate_inplace ()
3587
3587
3588
3588
if value is None :
3589
3589
if not isinstance (to_replace , (dict , Series )):
@@ -3615,8 +3615,8 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3615
3615
else :
3616
3616
to_replace , value = keys , values
3617
3617
3618
- return self .replace (to_replace , value , method = method , axis = axis ,
3619
- inplace = inplace , limit = limit , regex = regex ,
3618
+ return self .replace (to_replace , value , inplace = inplace ,
3619
+ limit = limit , regex = regex ,
3620
3620
infer_types = infer_types )
3621
3621
else :
3622
3622
if not len (self .columns ):
@@ -3629,7 +3629,7 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3629
3629
for c , src in to_replace .iteritems ():
3630
3630
if c in value and c in self :
3631
3631
new_data = new_data .replace (src , value [c ],
3632
- filter = [ c ],
3632
+ filter = [c ],
3633
3633
inplace = inplace ,
3634
3634
regex = regex )
3635
3635
@@ -3638,7 +3638,7 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3638
3638
for k , src in to_replace .iteritems ():
3639
3639
if k in self :
3640
3640
new_data = new_data .replace (src , value ,
3641
- filter = [ k ],
3641
+ filter = [ k ],
3642
3642
inplace = inplace ,
3643
3643
regex = regex )
3644
3644
else :
@@ -3667,9 +3667,8 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3667
3667
"regular expression or a list or dict of "
3668
3668
"strings or regular expressions, you "
3669
3669
"passed a {0}" .format (type (regex )))
3670
- return self .replace (regex , value , method = method , axis = axis ,
3671
- inplace = inplace , limit = limit , regex = True ,
3672
- infer_types = infer_types )
3670
+ return self .replace (regex , value , inplace = inplace , limit = limit ,
3671
+ regex = True , infer_types = infer_types )
3673
3672
else :
3674
3673
3675
3674
# dest iterable dict-like
@@ -3679,7 +3678,7 @@ def replace(self, to_replace=None, value=None, method='pad', axis=0,
3679
3678
for k , v in value .iteritems ():
3680
3679
if k in self :
3681
3680
new_data = new_data .replace (to_replace , v ,
3682
- filter = [ k ],
3681
+ filter = [k ],
3683
3682
inplace = inplace ,
3684
3683
regex = regex )
3685
3684
0 commit comments