Skip to content

Commit cb7a762

Browse files
committed
ENH: Correct documentation of DataFrame.rename (#13473)
1 parent 383bc59 commit cb7a762

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

Diff for: pandas/core/frame.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -3911,7 +3911,8 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
39113911

39123912
@rewrite_axis_style_signature('mapper', [('copy', True),
39133913
('inplace', False),
3914-
('level', None)])
3914+
('level', None),
3915+
('errors', 'ignore')])
39153916
def rename(self, *args, **kwargs):
39163917
"""
39173918
Alter axes labels.
@@ -3924,37 +3925,46 @@ def rename(self, *args, **kwargs):
39243925
39253926
Parameters
39263927
----------
3927-
mapper, index, columns : dict-like or function, optional
3928-
dict-like or functions transformations to apply to
3928+
mapper : dict-like or function
3929+
Dict-like or functions transformations to apply to
39293930
that axis' values. Use either ``mapper`` and ``axis`` to
39303931
specify the axis to target with ``mapper``, or ``index`` and
39313932
``columns``.
3932-
axis : int or str, optional
3933+
index : dict-like or function
3934+
Alternative to specifying axis (``mapper, axis=0``
3935+
is equivalent to ``index=labels``).
3936+
columns : dict-like or function
3937+
Alternative to specifying axis (``mapper, axis=1``
3938+
is equivalent to ``columns=mapper``).
3939+
axis : int or str
39333940
Axis to target with ``mapper``. Can be either the axis name
39343941
('index', 'columns') or number (0, 1). The default is 'index'.
3935-
copy : boolean, default True
3936-
Also copy underlying data
3937-
inplace : boolean, default False
3942+
copy : bool, default True
3943+
Also copy underlying data.
3944+
inplace : bool, default False
39383945
Whether to return a new DataFrame. If True then value of copy is
39393946
ignored.
39403947
level : int or level name, default None
39413948
In case of a MultiIndex, only rename labels in the specified
39423949
level.
39433950
errors : {'ignore', 'raise'}, default 'ignore'
39443951
If 'ignore', suppress error and existing labels are renamed.
3952+
39453953
Returns
39463954
-------
39473955
DataFrame
3948-
3949-
See Also
3950-
--------
3951-
DataFrame.rename_axis
3956+
DataFrame with the renamed axis labels.
39523957
39533958
Raises
39543959
------
39553960
KeyError
39563961
If any of the labels is not found in the selected axis.
39573962
3963+
See Also
3964+
--------
3965+
DataFrame.rename_axis: Set the name of the axis for the index or
3966+
columns.
3967+
39583968
Examples
39593969
--------
39603970

0 commit comments

Comments
 (0)