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

Timestamp losing nanosecond accuracy when reading from string #7878

Closed
cyber42 opened this issue Jul 30, 2014 · 3 comments · Fixed by #7907
Closed

Timestamp losing nanosecond accuracy when reading from string #7878

cyber42 opened this issue Jul 30, 2014 · 3 comments · Fixed by #7907

Comments

@cyber42
Copy link

cyber42 commented Jul 30, 2014

Hi,

I'm on pandas 0.14.1. Timestamp seems to lose nanoseconds when converting to string and back. Wonder if this is bug.

In [18]: pd.Timestamp('20010101 00:00:00')+pd.tseries.offsets.Nano()
Out[18]: Timestamp('2001-01-01 00:00:00.000000001')

In [19]: pd.Timestamp('2001-01-01 00:00:00.000000001')
Out[19]: Timestamp('2001-01-01 00:00:00')

Thanks,
Mark

INSTALLED VERSIONS

commit: None
python: 2.7.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.11.0-26-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8

pandas: 0.14.1
nose: 1.3.0
Cython: 0.19.2
numpy: 1.8.1
scipy: 0.13.2
statsmodels: 0.5.0
IPython: 0.13.2
sphinx: None
patsy: 0.2.1
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.2
bottleneck: 0.8.0
tables: 3.0.0
numexpr: 2.3
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.8
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None

@jreback
Copy link
Contributor

jreback commented Jul 30, 2014

hmm, #7610 should have fixed this

cc @sinhrks ?

@jreback jreback added this to the 0.15.0 milestone Jul 30, 2014
@sinhrks
Copy link
Member

sinhrks commented Jul 30, 2014

@jreback #7610 is for Timestamp instance with nanosecond. This looks a parsing problem.

@cyber42 You can use pd.to_datetime as workaround.

pd.to_datetime('2001-01-01 00:00:00.000000001')
# 2001-01-01 00:00:00.000000001

@sinhrks
Copy link
Member

sinhrks commented Jul 31, 2014

Briefly checked, there seems to be no parse function which can handle both nanosecond and tz. It looks better to create new internal parse function, and merge others.

pd.to_datetime('2001-01-01 00:00:00.000000001')
# 2001-01-01 00:00:00.000000001
pd.to_datetime('2001-01-01 00:00:00.000000001+9:00')
# 2000-12-31 15:00:00

pd.tslib.parse_date('2001-01-01 00:00:00.000000001')
# 2001-01-01 00:00:00
pd.tslib.parse_date('2001-01-01 00:00:00.000000001+9:00')
# 2001-01-01 00:00:00+09:00

# internal parse funcs
pd.tslib.parse_datetime_string('2001-01-01 00:00:00.000000001')
# 2001-01-01 00:00:00
pd.tslib.parse_datetime_string('2001-01-01 00:00:00.000000001+9:00')
# 2001-01-01 00:00:00+09:00

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

Successfully merging a pull request may close this issue.

3 participants