Skip to content
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

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

Closed
wesm opened this issue Mar 14, 2016 · 2 comments
Closed

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

wesm opened this issue Mar 14, 2016 · 2 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string

Comments

@wesm
Copy link
Member

wesm commented Mar 14, 2016

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'
@jreback
Copy link
Contributor

jreback commented Mar 14, 2016

not useful.......but

In [4]: pprint.saferepr(d)
Out[4]: "{'bar': [{'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}, {'what': {'footttttttttttttttttttttttttttttttttt': Timestamp('2011-01-01 00:00:00')}}], 'foo': 1}"

@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Mar 14, 2016
@jreback
Copy link
Contributor

jreback commented Mar 14, 2016

I think if we could define _Timestamp to actually use __slots__. http://stackoverflow.com/questions/10401935/python-method-wrapper-type

but not really sure how cython does this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants