Skip to content

BUG: GH12622 where pprint of Timestamp in nested structure fails #12629

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 1 commit into from

Conversation

kawochen
Copy link
Contributor

I suspect this is a bug in Cython (I don't think type(A).func should be an instancemethod). Not sure if we should use this workaround as we encounter issues in the wild, or do this for all the functions we can think of.

@@ -977,6 +953,30 @@ cdef class _Timestamp(datetime):
self._assert_tzawareness_compat(other)
return _cmp_scalar(self.value, ots.value, op)

def __repr__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so moving this to _Timestamp worked, interesting. Should move any referenced functions as well ,e.g. ._repr_base. _date_repr & _time_repr for consistency.

@jreback jreback added this to the 0.18.1 milestone Mar 15, 2016
@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Mar 15, 2016
@kawochen
Copy link
Contributor Author

updated

@jreback
Copy link
Contributor

jreback commented Mar 18, 2016

@wesm this work for you?

@jreback
Copy link
Contributor

jreback commented Mar 18, 2016

@kawochen let's put a test in for Timedelta. I think it has the same issue.

@wesm
Copy link
Member

wesm commented Mar 25, 2016

Looks like this should work. Cython esoterica!

@jreback jreback closed this in 33659fd Mar 25, 2016
@jreback
Copy link
Contributor

jreback commented Mar 25, 2016

thanks @kawochen

@jreback
Copy link
Contributor

jreback commented Mar 25, 2016

@kawochen forgot to test for Timedelta, can you do a pr which adds?

Though does seem to work

In [7]: d = {'foo': 1, 'bar': [{'what': {'footttttttttttttttttttttttttttttttttt': pd.Timestamp('2011-01-01')}}] * 10, 'baz': [{'what': {'footttttttttttttttttttttttttttttttttt': pd.Timedelta('1 day 1 min')}}] * 10} 
In [8]: d
Out[8]: 
{'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')}}],
 'baz': [{'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
  {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}}],
 'foo': 1}

In [9]: pprint.pprint(d)
{'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')}}],
 'baz': [{'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}},
         {'what': {'footttttttttttttttttttttttttttttttttt': Timedelta('1 days 00:01:00')}}],
 'foo': 1}

@kawochen
Copy link
Contributor Author

No problem. Was going to update today :)

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 this pull request may close these issues.

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