@@ -742,6 +742,7 @@ def swaplevel(self, i=-2, j=-1, axis=0):
742742
743743 Parameters
744744 ----------
745+ %(mapper)s
745746 %(axes)s : scalar, list-like, dict-like or function, optional
746747 Scalar or list-like will alter the ``Series.name`` attribute,
747748 and raise on DataFrame or Panel.
@@ -787,6 +788,7 @@ def swaplevel(self, i=-2, j=-1, axis=0):
787788 3 2
788789 5 3
789790 dtype: int64
791+
790792 >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
791793 >>> df.rename(2)
792794 Traceback (most recent call last):
@@ -802,10 +804,25 @@ def swaplevel(self, i=-2, j=-1, axis=0):
802804 0 1 4
803805 1 2 5
804806 2 3 6
807+
808+ Using axis-style parameters
809+
810+ >>> df.rename(str.lower, axis='columns')
811+ A B
812+ 0 1 4
813+ 1 2 5
814+ 2 3 6
815+
816+ >>> df.rename({1: 2, 2: 4}, axis='index')
817+ A B
818+ 0 1 4
819+ 2 2 5
820+ 4 3 6
805821 """
806822
807823 @Appender (_shared_docs ['rename' ] % dict (axes = 'axes keywords for this'
808- ' object' , klass = 'NDFrame' ))
824+ ' object' , klass = 'NDFrame' ,
825+ mapper = '' ))
809826 def rename (self , * args , ** kwargs ):
810827 axes , kwargs = self ._construct_axes_from_arguments (args , kwargs )
811828 copy = kwargs .pop ('copy' , True )
0 commit comments