Skip to content

Commit 88c9638

Browse files
committed
test for iadd and isub preserving name
1 parent ef845af commit 88c9638

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexes/test_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,17 @@ def test_addsub_arithmetic(self, dtype, delta):
19881988
tm.assert_index_equal(idx - idx, 0 * idx)
19891989
assert not (idx - idx).empty
19901990

1991+
def test_iadd_preserves_name(self):
1992+
# GH#17067, GH#19723 __iadd__ and __isub__ should preserve index name
1993+
ser = pd.Series([1, 2, 3])
1994+
ser.index.name = 'foo'
1995+
1996+
ser.index += 1
1997+
assert ser.index.name == "foo"
1998+
1999+
ser.index -= 1
2000+
assert ser.index.name == "foo"
2001+
19912002

19922003
class TestMixedIntIndex(Base):
19932004
# Mostly the tests from common.py for which the results differ

0 commit comments

Comments
 (0)