From b5819564dcdcdb086a1de49a8f6f9b180bbf32ff Mon Sep 17 00:00:00 2001 From: Jeffrey Tratner Date: Sun, 6 Oct 2013 18:23:17 -0400 Subject: [PATCH] BUG: set_names should not change is_ relationship --- pandas/core/index.py | 1 - pandas/tests/test_index.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index c39364d58e205..8e98cc6fb25bb 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -335,7 +335,6 @@ def set_names(self, names, inplace=False): raise TypeError("Must pass list-like as `names`.") if inplace: idx = self - idx._reset_identity() else: idx = self._shallow_copy() idx._set_names(names) diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index a568b72a9ace6..5404b30af8d1c 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -1887,6 +1887,9 @@ def test_is_(self): self.assertTrue(mi2.is_(mi)) self.assertTrue(mi.is_(mi2)) self.assertTrue(mi.is_(mi.set_names(["C", "D"]))) + mi2 = mi.view() + mi2.set_names(["E", "F"], inplace=True) + self.assertTrue(mi.is_(mi2)) # levels are inherent properties, they change identity mi3 = mi2.set_levels([lrange(10), lrange(10)]) self.assertFalse(mi3.is_(mi2))