|
| 1 | +from collections import ChainMap |
1 | 2 | from datetime import datetime, timedelta
|
2 | 3 | import inspect
|
3 | 4 |
|
@@ -691,6 +692,24 @@ def test_rename(self, float_frame):
|
691 | 692 | tm.assert_index_equal(renamed.index, Index(["bar", "foo"], name="name"))
|
692 | 693 | assert renamed.index.name == renamer.index.name
|
693 | 694 |
|
| 695 | + @pytest.mark.parametrize( |
| 696 | + "args,kwargs", |
| 697 | + [ |
| 698 | + ((ChainMap({"A": "a"}, {"B": "b"}),), dict(axis="columns")), |
| 699 | + ((), dict(columns=ChainMap({"A": "a"}, {"B": "b"}))), |
| 700 | + ], |
| 701 | + ) |
| 702 | + def test_rename_chainmap(self, args, kwargs): |
| 703 | + # see gh-23859 |
| 704 | + colAData = range(1, 11) |
| 705 | + colBdata = np.random.randn(10) |
| 706 | + |
| 707 | + df = DataFrame({"A": colAData, "B": colBdata}) |
| 708 | + result = df.rename(*args, **kwargs) |
| 709 | + |
| 710 | + expected = DataFrame({"a": colAData, "b": colBdata}) |
| 711 | + tm.assert_frame_equal(result, expected) |
| 712 | + |
694 | 713 | def test_rename_axis_inplace(self, float_frame):
|
695 | 714 | # GH 15704
|
696 | 715 | expected = float_frame.rename_axis("foo")
|
|
0 commit comments