Skip to content

Loss of nanosecond resolution when constructing Timestamps from str #10041

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
multiloc opened this issue May 1, 2015 · 1 comment
Closed
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@multiloc
Copy link
Contributor

multiloc commented May 1, 2015

Looks like a bug: When passing a YYYYMMDDTHHMMSS.f string to pd.Timestamp, the resolution seems limited to micro- rather than nano-seconds:

>>> pd.Timestamp('20130101T000000.000001+0000')
Timestamp('2013-01-01 00:00:00.000001+0000', tz='UTC')

>>> pd.Timestamp('20130101T000000.0000001+0000')
Timestamp('2013-01-01 00:00:00+0000', tz='UTC')

>>> pd.Timestamp('20130101T000000.00000001+0000')
Timestamp('2013-01-01 00:00:00+0000', tz='UTC')

The behavior seems correct when using a different string format:

>>> pd.Timestamp('2013-01-01 00:00:00.00000001+0000')
Timestamp('2013-01-01 00:00:00.000000010+0000', tz='UTC')

Using pandas 0.16.0, python 2.7.6

@sinhrks sinhrks added the Datetime Datetime data dtype label May 4, 2015
@sinhrks
Copy link
Member

sinhrks commented May 4, 2015

Because dateutil doesn't support nanosecond, it looks little difficult to cover all the cases to nanoseconds (see #7907).

One option is to prepare a nanosecond parser to support some popular date formats. For example, change (or prepare separate function like) np_datetime_string.c to allow formats with other separators or without separators (like suggested in #9714).

A PR would be appreciated :)

@jreback jreback added the Bug label May 4, 2015
@jreback jreback added this to the Next Major Release milestone May 4, 2015
@jreback jreback modified the milestones: 0.18.0, Next Major Release Mar 3, 2016
@jreback jreback closed this as completed in 60b307f Mar 5, 2016
@jreback jreback reopened this Mar 5, 2016
@jreback jreback modified the milestones: 0.18.1, 0.18.0 Mar 5, 2016
@jreback jreback closed this as completed in 820e110 Mar 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants