Skip to content

Commit b837101

Browse files
committed
BUG: fix Series repr when name is tuple holding non string-type
1 parent 8ea1a51 commit b837101

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

pandas/core/format.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
except:
99
from io import StringIO
1010

11-
from pandas.core.common import adjoin, isnull, notnull, _stringify
11+
from pandas.core.common import (adjoin, isnull, notnull, _stringify,
12+
_stringify_seq)
1213
from pandas.core.index import MultiIndex, _ensure_index
1314
from pandas.util import py3compat
1415

@@ -85,7 +86,8 @@ def _get_footer(self):
8586
if isinstance(self.series.name, basestring):
8687
series_name = self.series.name
8788
elif isinstance(self.series.name, tuple):
88-
series_name = "('%s')" % "', '".join(self.series.name)
89+
series_name = "('%s')" % "', '".join(
90+
_stringify_seq(self.series.name))
8991
else:
9092
series_name = str(self.series.name)
9193
else:

pandas/tests/test_series.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1011,9 +1011,16 @@ def test_repr(self):
10111011
ots[::2] = None
10121012
repr(ots)
10131013

1014-
# tuple name, e.g. from hierarchical index
1015-
self.series.name = ('foo', 'bar', 'baz')
1016-
repr(self.series)
1014+
# various names
1015+
for name in ['', 1, 1.2, 'foo', u'\u03B1\u03B2\u03B3',
1016+
'loooooooooooooooooooooooooooooooooooooooooooooooooooong',
1017+
('foo', 'bar', 'baz'),
1018+
(1, 2),
1019+
('foo', 1, 2.3),
1020+
(u'\u03B1', u'\u03B2', u'\u03B3'),
1021+
(u'\u03B1', 'bar')]:
1022+
self.series.name = name
1023+
repr(self.series)
10171024

10181025
biggie = Series(tm.randn(1000), index=np.arange(1000),
10191026
name=('foo', 'bar', 'baz'))

0 commit comments

Comments
 (0)