From 38f2a8050dfd68eb0cb496c2604cdf57effbba52 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 1 Dec 2018 12:32:33 -0500 Subject: [PATCH 1/2] DOC: Improve "inplace" param in Dataframe.rename() docs --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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. From f273ef05303797c8992c4402bf1d5e6e18f23daf Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 1 Dec 2018 12:32:51 -0500 Subject: [PATCH 2/2] TST: Assert result of in-place rename is None --- pandas/tests/frame/test_alter_axes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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