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

ENH/CLN: make Timestamp repr valid python code, like datetime does. #3379

Merged
2 commits merged into from Apr 23, 2013
Merged

ENH/CLN: make Timestamp repr valid python code, like datetime does. #3379

2 commits merged into from Apr 23, 2013

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