Skip to content

Fix precision drop when indexing a datetime64 arrays. #1942

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 3 commits into from
Feb 27, 2018

Conversation

fujiisoup
Copy link
Member

This precision drop was caused when converting pd.Timestamp to np.array

In [7]: ts = pd.Timestamp(np.datetime64('2018-02-12 06:59:59.999986560'))
In [11]: np.asarray(ts, 'datetime64[ns]')
Out[11]: array('2018-02-12T06:59:59.999986000', dtype='datetime64[ns]')

We need to call to_datetime64 explicitly.

@shoyer
Copy link
Member

shoyer commented Feb 26, 2018

Were you able to identify the underlying issue? This feels like something that might likely be a bug in pandas or numpy.

@fujiisoup
Copy link
Member Author

It looks that numpy fails to cast pd.Timestamp to np.datetime64[ns].
But I am not sure it is an expected behavior.

I added a link to numpy's issue.

Copy link
Member

@shoyer shoyer left a comment

Choose a reason for hiding this comment

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

Thanks for adding the issue link. This makes sense to me now.

@fujiisoup fujiisoup merged commit d8ccc7a into pydata:master Feb 27, 2018
@fujiisoup fujiisoup deleted the fix_1932 branch June 8, 2018 01:21
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