Skip to content

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

@lodagro

Description

@lodagro
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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions