@@ -2777,7 +2777,7 @@ def _replace_both_dict(self, to_replace, value, inplace):
2777
2777
#----------------------------------------------------------------------
2778
2778
# Rename
2779
2779
2780
- def rename (self , index = None , columns = None , copy = True ):
2780
+ def rename (self , index = None , columns = None , copy = True , inplace = False ):
2781
2781
"""
2782
2782
Alter index and / or columns using input function or
2783
2783
functions. Function / dict values must be unique (1-to-1). Labels not
@@ -2791,6 +2791,9 @@ def rename(self, index=None, columns=None, copy=True):
2791
2791
Transformation to apply to column values
2792
2792
copy : boolean, default True
2793
2793
Also copy underlying data
2794
+ inplace : boolean, default False
2795
+ Whether to return a new DataFrame. If True then value of copy is
2796
+ ignored.
2794
2797
2795
2798
See also
2796
2799
--------
@@ -2810,7 +2813,7 @@ def rename(self, index=None, columns=None, copy=True):
2810
2813
2811
2814
self ._consolidate_inplace ()
2812
2815
2813
- result = self .copy (deep = copy )
2816
+ result = self if inplace else self .copy (deep = copy )
2814
2817
2815
2818
if index is not None :
2816
2819
result ._rename_index_inplace (index_f )
0 commit comments