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

Floating point accuracy problems in Timestamp.round #14572

Closed
jeanmn opened this issue Nov 3, 2016 · 4 comments
Closed

Floating point accuracy problems in Timestamp.round #14572

jeanmn opened this issue Nov 3, 2016 · 4 comments
Labels
Duplicate Report Duplicate issue or pull request Timeseries

Comments

@jeanmn
Copy link

jeanmn commented Nov 3, 2016

This is the same problem as described in #14440 but with Timestamp, and the fix should be similar.

Probable source of error:

result = Timestamp(unit * rounder(value / float(unit)), unit='ns')

A small, complete example of the issue

In [1] import pandas as pd
In [2]: ts=pd.Timestamp('2016-03-06 18:43:45.950000')
In [3]: ts.floor('10L')
Out [3]: Timestamp('2016-03-06 18:43:45.950000128')  

Expected Output

Timestamp('2016-03-06 18:43:45.950000')

Output of pd.show_versions()

INSTALLED VERSIONS

commit: 093aa82
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.16.0-46-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.19.0+63.g093aa82
nose: 1.3.7
pip: 9.0.0
setuptools: 28.7.1
Cython: 0.25.1
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None

@jreback jreback added Timeseries Duplicate Report Duplicate issue or pull request labels Nov 3, 2016
@jreback jreback added this to the No action milestone Nov 3, 2016
@jreback
Copy link
Contributor

jreback commented Nov 3, 2016

duplicate

@jreback jreback closed this as completed Nov 3, 2016
@jeanmn
Copy link
Author

jeanmn commented Nov 3, 2016

@jreback Issue link? I was on the verge of submitting a pull request to fix this

@jreback
Copy link
Contributor

jreback commented Nov 3, 2016

#14440 as u indicated

pr are welcome for this (it's an issue duplicate)

@jeanmn
Copy link
Author

jeanmn commented Nov 3, 2016

@jreback I see, thank you for the clarification.
I just wanted to make clear that this is a similar issue but at a different location in the code due to duplication of internal rounding logic. I wouldn't be surprised if the same error is found in more locations.
FYI: The current affected classes (so far) are Timestamp, Timedelta and DatetimeIndex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Timeseries
Projects
None yet
Development

No branches or pull requests

2 participants