113113 by : str or list of str
114114 Name or list of names which refer to the axis items.""" ,
115115 versionadded_to_excel = '' ,
116- mapper = """mapper : dict-like or function
116+ mapper = """mapper : dict-like or function
117117 Applied to the axis specified by `axis`""" ,
118118)
119119
@@ -2911,11 +2911,12 @@ def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
29112911 def rename (self , mapper = None , index = None , columns = None , axis = None ,
29122912 ** kwargs ):
29132913 if axis is not None :
2914+ # Using "axis" style, along with a positional mapper
2915+ # Both index and columns should be None then
29142916 axis = self ._get_axis_name (axis )
2915- # interpreting 'mapper' as a positional argument
29162917 if index is not None or columns is not None :
2917- raise TypeError ("Can't specify 'index' or 'columns ' and 'axis' "
2918- " at the same time. Specify either\n "
2918+ raise TypeError ("Can't specify both 'axis ' and 'index' or "
2919+ "'columns' Specify either\n "
29192920 "\t .rename(mapper, axis=axis), or\n "
29202921 "\t .rename(index=index, columns=columns)" )
29212922 if axis == 'index' :
@@ -2929,8 +2930,10 @@ def rename(self, mapper=None, index=None, columns=None, axis=None,
29292930 elif axis is None and (mapper is not None and index is not None ):
29302931 # Determine if they meant df.rename(idx_map, col_map)
29312932 if callable (index ) or is_dict_like (index ):
2932- warnings .warn ("Interpreting renaming index and columns. "
2933- "Use keyword arguments." , UserWarning )
2933+ warnings .warn ("Interpreting call to '.rename(a, b)' as "
2934+ "'.rename(index=a, columns=b)'. "
2935+ "Use keyword arguments to remove ambiguity." ,
2936+ UserWarning )
29342937 index , columns = mapper , index
29352938 elif index is None and columns is None :
29362939 index = mapper
0 commit comments