Skip to content

Commit

Permalink
Add whatsnew note and additional tests for rename_axis(inplace=True)
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Jun 10, 2017
1 parent c331134 commit 6da584b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Other Enhancements
- The ``validate`` argument for :func:`merge` function now checks whether a merge is one-to-one, one-to-many, many-to-one, or many-to-many. If a merge is found to not be an example of specified merge type, an exception of type ``MergeError`` will be raised. For more, see :ref:`here <merging.validation>` (:issue:`16270`)
- ``Series.to_dict()`` and ``DataFrame.to_dict()`` now support an ``into`` keyword which allows you to specify the ``collections.Mapping`` subclass that you would like returned. The default is ``dict``, which is backwards compatible. (:issue:`16122`)
- ``RangeIndex.append`` now returns a ``RangeIndex`` object when possible (:issue:`16212`)
- ``Series.rename_axis()`` and ``DataFrame.rename_axis()`` with ``inplace=True`` now return None while renaming the axis inplace. (:issue:`15704`)
- :func:`to_pickle` has gained a protocol parameter (:issue:`16252`). By default, this parameter is set to `HIGHEST_PROTOCOL <https://docs.python.org/3/library/pickle.html#data-stream-format>`__
- :func:`api.types.infer_dtype` now infers decimals. (:issue: `15690`)
- :func:`read_feather` has gained the ``nthreads`` parameter for multi-threaded operations (:issue:`16359`)
Expand Down
15 changes: 12 additions & 3 deletions pandas/tests/frame/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,19 @@ def test_rename(self):

def test_rename_axis_inplace(self):
# GH 15704
expected = self.frame.rename_axis('foo')
no_return = self.frame.rename_axis('foo', inplace=True)
frame = self.frame.copy()
expected = frame.rename_axis('foo')
result = frame.copy()
no_return = result.rename_axis('foo', inplace=True)

assert no_return is None
assert_frame_equal(result, expected)

expected = frame.rename_axis('bar', axis=1)
result = frame.copy()
no_return = result.rename_axis('bar', axis=1, inplace=True)

assert no_return is None
result = self.frame
assert_frame_equal(result, expected)

def test_rename_multiindex(self):
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/series/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,13 @@ def test_reorder_levels(self):

result = s.reorder_levels(['L0', 'L0', 'L0'])
assert_series_equal(result, expected)

def test_rename_axis_inplace(self):
# GH 15704
series = self.ts.copy()
expected = series.rename_axis('foo')
result = series.copy()
no_return = result.rename_axis('foo', inplace=True)

assert no_return is None
assert_series_equal(result, expected)

0 comments on commit 6da584b

Please sign in to comment.