Skip to content

Floating point accuracy problems in Timestamp.round  #14572

Closed
@jeanmn

Description

@jeanmn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeDuplicate ReportDuplicate issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions