Skip to content

Series repr failure when name is tuple holding non-string type. #2051

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
lodagro opened this issue Oct 10, 2012 · 0 comments
Closed

Series repr failure when name is tuple holding non-string type. #2051

lodagro opened this issue Oct 10, 2012 · 0 comments
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@lodagro
Copy link
Contributor

lodagro commented Oct 10, 2012

In [140]: s = pd.Series(list('abcd'), name=('foo', 1))

In [141]: s
Out[141]: ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...

.../pandas/core/format.pyc in _get_footer(self)
     86                     series_name = self.series.name
     87                 elif isinstance(self.series.name, tuple):
---> 88                     series_name = "('%s')" % "', '".join(self.series.name)
     89                 else:
     90                     series_name = str(self.series.name)
TypeError: sequence item 1: expected string, int found

Found the issue when indexing a MultiIndexed frame.

In [142]: mi = pd.MultiIndex.from_tuples([('foo', 1), ('foo', 2)])

In [143]: df = pd.DataFrame(np.random.randn(2,2), index=mi)

In [144]: df.ix[('foo', 1)]
Out[144]: ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

2 participants