Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Apr 17, 2013

In the same vein as #3038 , make repr() output valid python code where feasible. I find this not
being the case inconvenient for example when issues contain code examples,
and the data needs to be recreated by hand rather then merely copy pasted.

In [2]: zs=[Timestamp('99-04-17 00:00:00',tz='UTC'),
   ...: Timestamp('2001-04-17 00:00:00',tz='UTC'),
   ...: Timestamp('2001-04-17 00:00:00',tz='America/Los_Angeles'),
   ...: Timestamp('2001-04-17 00:00:00',tz=None)]
   ...: for z in zs:
   ...:     print repr(z)
   ...:     assert eval(repr(z)) == z
Timestamp('1999-04-17 00:00:00+0000', tz='UTC')
Timestamp('2001-04-17 00:00:00+0000', tz='UTC')
Timestamp('2001-04-17 00:00:00-0700', tz='America/Los_Angeles')
Timestamp('2001-04-17 00:00:00', tz=None)

Misgivings?

@jreback
Copy link
Contributor

jreback commented Apr 17, 2013

looks ok to me

@hayd
Copy link
Contributor

hayd commented Apr 17, 2013

Great ENH.

ghost pushed a commit that referenced this pull request Apr 23, 2013
ENH/CLN: make Timestamp repr valid python code, like datetime does.
@ghost ghost merged commit c28d2cd into pandas-dev:master Apr 23, 2013
@ghost ghost deleted the timestamp_repr branch April 23, 2013 02:13
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants