Loss of nanosecond resolution when constructing Timestamps from str #10041

Closed
hcontrast opened this Issue May 1, 2015 · 1 comment

Comments

Projects
None yet
3 participants
Contributor

hcontrast 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 added the Timeseries label May 4, 2015

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 added the Bug label May 4, 2015

jreback added this to the Next Major Release milestone May 4, 2015

@jreback jreback modified the milestone: 0.18.0, Next Major Release Mar 3, 2016

jreback closed this in 60b307f Mar 5, 2016

jreback reopened this Mar 5, 2016

@jreback jreback modified the milestone: 0.18.1, 0.18.0 Mar 5, 2016

jreback closed this in 820e110 Mar 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment