Skip to content

BUG: fix Series repr when name is tuple holding non string-type #2059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 14 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ Where to get it
* Binary installers on PyPI: http://pypi.python.org/pypi/pandas
* Documentation: http://pandas.pydata.org

pandas 0.10.0
=============

**Release date:** not yet released

**New features**

**Improvements to existing features**

**Bug fixes**

- fix Series repr when name is tuple holding non string-type (#2051)


pandas 0.9.0
============

Expand Down
6 changes: 4 additions & 2 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
except:
from io import StringIO

from pandas.core.common import adjoin, isnull, notnull, _stringify
from pandas.core.common import (adjoin, isnull, notnull, _stringify,
_stringify_seq)
from pandas.core.index import MultiIndex, _ensure_index
from pandas.util import py3compat

Expand Down Expand Up @@ -85,7 +86,8 @@ def _get_footer(self):
if isinstance(self.series.name, basestring):
series_name = self.series.name
elif isinstance(self.series.name, tuple):
series_name = "('%s')" % "', '".join(self.series.name)
series_name = "('%s')" % "', '".join(
_stringify_seq(self.series.name))
else:
series_name = str(self.series.name)
else:
Expand Down
13 changes: 10 additions & 3 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,16 @@ def test_repr(self):
ots[::2] = None
repr(ots)

# tuple name, e.g. from hierarchical index
self.series.name = ('foo', 'bar', 'baz')
repr(self.series)
# various names
for name in ['', 1, 1.2, 'foo', u'\u03B1\u03B2\u03B3',
'loooooooooooooooooooooooooooooooooooooooooooooooooooong',
('foo', 'bar', 'baz'),
(1, 2),
('foo', 1, 2.3),
(u'\u03B1', u'\u03B2', u'\u03B3'),
(u'\u03B1', 'bar')]:
self.series.name = name
repr(self.series)

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