diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 06519da9a26d5..39c54c720fef6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3909,8 +3909,8 @@ def rename(self, *args, **kwargs): copy : boolean, default True Also copy underlying data inplace : boolean, default False - Whether to return a new DataFrame. If True then value of copy is - ignored. + If True, perform the operation in-place, modifying this DataFrame, + and return None. level : int or level name, default None In case of a MultiIndex, only rename labels in the specified level. diff --git a/pandas/tests/frame/test_alter_axes.py b/pandas/tests/frame/test_alter_axes.py index 33128a8ab179a..7be9929d713ab 100644 --- a/pandas/tests/frame/test_alter_axes.py +++ b/pandas/tests/frame/test_alter_axes.py @@ -678,8 +678,9 @@ def test_rename_inplace(self, float_frame): c_id = id(float_frame['C']) float_frame = float_frame.copy() - float_frame.rename(columns={'C': 'foo'}, inplace=True) + result = float_frame.rename(columns={'C': 'foo'}, inplace=True) + assert result is None assert 'C' not in float_frame assert 'foo' in float_frame assert id(float_frame['foo']) != c_id