Skip to content

ENH: add Timestamp.to_datetime64 #9255

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

Merged
merged 1 commit into from
Jan 15, 2015
Merged

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Jan 15, 2015

This PR adds a Timestamp.to_datetime64() method to complement the Timedelta.to_timedelta64() method I added in #8884. It is a continuation of the aborted #8916.

Arguably, there should also be the alias Timestamp.values to complement the series property but I haven't added that yet.

@shoyer shoyer added this to the 0.16.0 milestone Jan 15, 2015
@shoyer shoyer added the Datetime Datetime data dtype label Jan 15, 2015
@jreback
Copy link
Contributor

jreback commented Jan 15, 2015

hmm, its called Timestamp.value; you think .values should also be there? why? (its not a big deal, but curious why)

@shoyer
Copy link
Member Author

shoyer commented Jan 15, 2015

Timstamp.value is an integer; .values would be a np.datetime64 object, like the datetime64 .values on arrays.

@jreback
Copy link
Contributor

jreback commented Jan 15, 2015

hmm that could be useful

@shoyer
Copy link
Member Author

shoyer commented Jan 15, 2015

Any comments on this PR? (Tests are green)

@@ -136,6 +136,20 @@ def test_constructor_with_stringoffset(self):
self.assertEqual(repr(result), expected_repr)
self.assertEqual(result, eval(repr(result)))

def test_conversion(self):
ts = Timestamp('2000-01-01')
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue as a comment here

@jreback
Copy link
Contributor

jreback commented Jan 15, 2015

trivial comment. looks good otherwise. you are picking up pieces from those other pr's yes?

@shoyer
Copy link
Member Author

shoyer commented Jan 15, 2015

@jreback By other PRs do you mean #8916? Yes, probably, eventually. Not entirely sure it's possible though given numpy datetime64 limitations :).

I wrote this one because I need it for the next PR I'm submitting tonight.

@jreback
Copy link
Contributor

jreback commented Jan 15, 2015

@shoyer yep. you had some good stuff in there IIRC.

shoyer added a commit that referenced this pull request Jan 15, 2015
ENH: add Timestamp.to_datetime64
@shoyer shoyer merged commit bbddca4 into pandas-dev:master Jan 15, 2015
@shoyer shoyer deleted the to_datetime64 branch January 15, 2015 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants