From 1c720f545079dcce7f5eabb343ef6c84cb3d67c5 Mon Sep 17 00:00:00 2001 From: jreback Date: Sun, 29 Sep 2013 15:13:51 -0400 Subject: [PATCH 1/2] API: copy Index when creating in a Series to avoid aliasing --- pandas/core/series.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 90d535e51580c..4a77a5669948a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -135,6 +135,12 @@ def __init__(self, data=None, index=None, dtype=None, name=None, if isinstance(data, MultiIndex): raise NotImplementedError + elif isinstance(data, Index): + # need to copy to avoid aliasing issues + if name is None: + name = data.name + data = data.values + copy = True elif isinstance(data, pa.Array): pass elif isinstance(data, Series): From a9626d213ab941333f37082ffbef1dcd1f448935 Mon Sep 17 00:00:00 2001 From: jreback Date: Sun, 29 Sep 2013 15:52:10 -0400 Subject: [PATCH 2/2] TST: fix failing unicode comparison test on sparc (with non-standard encoding) --- pandas/tests/test_index.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index bb46d563b904e..852d02764affc 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -2221,9 +2221,10 @@ def test_tolist(self): self.assertEqual(result, exp) def test_repr_with_unicode_data(self): - d = {"a": [u("\u05d0"), 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]} - index = pd.DataFrame(d).set_index(["a", "b"]).index - self.assertFalse("\\u" in repr(index)) # we don't want unicode-escaped + with pd.core.config.option_context("display.encoding",'UTF-8'): + d = {"a": [u("\u05d0"), 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]} + index = pd.DataFrame(d).set_index(["a", "b"]).index + self.assertFalse("\\u" in repr(index)) # we don't want unicode-escaped def test_unicode_string_with_unicode(self): d = {"a": [u("\u05d0"), 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}