@@ -114,8 +114,9 @@ class NDFrame(PandasObject, SelectionMixin):
114114 '__array_interface__' ]
115115 _internal_names_set = set (_internal_names )
116116 _accessors = frozenset ([])
117- _deprecations = frozenset (['as_blocks' , 'blocks' ,
118- 'consolidate' , 'convert_objects' , 'is_copy' ])
117+ _deprecations = frozenset (['as_blocks' , 'add_prefix' , 'add_suffix' ,
118+ 'blocks' , 'consolidate' , 'convert_objects' ,
119+ 'is_copy' ])
119120 _metadata = []
120121 _is_copy = None
121122
@@ -801,6 +802,11 @@ def swaplevel(self, i=-2, j=-1, axis=0):
801802 1 2
802803 4 3
803804 dtype: int64
805+ >>> s.rename('index_{}'.format) # function, changes labels
806+ index_0 1
807+ index_1 2
808+ index_2 3
809+ dtype: object
804810 >>> s.rename({1: 3, 2: 5}) # mapping, changes labels
805811 0 1
806812 3 2
@@ -824,11 +830,11 @@ def swaplevel(self, i=-2, j=-1, axis=0):
824830 We *highly* recommend using keyword arguments to clarify your
825831 intent.
826832
827- >>> df.rename(index=str , columns={"A": "a", "B": "c"})
828- a c
829- 0 1 4
830- 1 2 5
831- 2 3 6
833+ >>> df.rename(index="index_{}".format , columns={"A": "a", "B": "c"})
834+ a c
835+ index_0 1 4
836+ index_1 2 5
837+ index_2 3 6
832838
833839 >>> df.rename(index=str, columns={"A": "a", "C": "c"})
834840 a B
@@ -2922,6 +2928,8 @@ def _update_inplace(self, result, verify_is_copy=True):
29222928
29232929 def add_prefix (self , prefix ):
29242930 """
2931+ DEPRECATED: Use ``obj.rename(columns=lambda x: 'prefix_'+str(x))`` or similar instead.
2932+
29252933 Concatenate prefix string with panel items names.
29262934
29272935 Parameters
@@ -2931,12 +2939,19 @@ def add_prefix(self, prefix):
29312939 Returns
29322940 -------
29332941 with_prefix : type of caller
2942+
2943+ See Also:
2944+ ---------
2945+ rename : Alter axes labels.
29342946 """
2947+ warnings .warn ("'.add_prefix' is deprecated and will be removed in a "
2948+ "future version. Use '.rename' instead" , FutureWarning , stacklevel = 2 )
29352949 new_data = self ._data .add_prefix (prefix )
29362950 return self ._constructor (new_data ).__finalize__ (self )
29372951
29382952 def add_suffix (self , suffix ):
29392953 """
2954+ DEPRECATED: Use ``obj.rename(columns=lambda x: 'prefix_'+str(x))`` or similar instead.
29402955 Concatenate suffix string with panel items names.
29412956
29422957 Parameters
@@ -2946,7 +2961,13 @@ def add_suffix(self, suffix):
29462961 Returns
29472962 -------
29482963 with_suffix : type of caller
2964+
2965+ See Also:
2966+ ---------
2967+ rename : Alter axes labels.
29492968 """
2969+ warnings .warn ("'add_suffix' is deprecated and will be removed in a "
2970+ "future version." , FutureWarning , stacklevel = 2 )
29502971 new_data = self ._data .add_suffix (suffix )
29512972 return self ._constructor (new_data ).__finalize__ (self )
29522973
0 commit comments