Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down