Skip to content

BUG: pandas.Timestamp misbehaves in deeply nested pprint on Python 3 #12622

Closed
@wesm

Description

@wesm

I'm not sure if we can fix this in pandas, but I ran into this recently:

In [10]: d = {'foo': 1, 'bar': [{'what': {'footttttttttttttttttttttttttttttttttt': pd.Timestamp('2011-01-01')}}] * 10}

In [11]: pprint.pprint(d)
<SNIP>
lib/python3.5/pprint.py in _format_dict_items(self, items, stream, indent, allowance, context, level)
    344             self._format(ent, stream, indent + len(rep) + 2,
    345                          allowance if last else 1,
--> 346                          context, level)
    347             if not last:
    348                 write(delimnl)

lib/python3.5/pprint.py in _format(self, object, stream, indent, allowance, context, level)
    162         max_width = self._width - indent - allowance
    163         if len(rep) > max_width:
--> 164             p = self._dispatch.get(type(object).__repr__, None)
    165             if p is not None:
    166                 context[objid] = 1

TypeError: unhashable type: 'instancemethod'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Output-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions