Closed
Description
Code Sample, a copy-pastable example if possible
>>> pd.DataFrame([dict(a_float=0.95)]).to_json(double_precision=1)
'{"a_float":{"0":0.1}}'
>>> pd.DataFrame([dict(a_float=1.95)]).to_json(double_precision=1)
'{"a_float":{"0":1.1}}'
>>> pd.DataFrame([dict(a_float=-1.95)]).to_json(double_precision=1)
'{"a_float":{"0":-1.1}}'
>>> pd.DataFrame([dict(a_float=0.995)]).to_json(double_precision=2)
'{"a_float":{"0":0.1}}'
>>> pd.DataFrame([dict(a_float=0.9995)]).to_json(double_precision=3)
'{"a_float":{"0":0.1}}'
Problem description
This issue is very similar to #15716.
Just this one reveals a more generalized pattern.
Expected Output
'{"a_float":{"0":1.0}}'
'{"a_float":{"0":2.0}}'
'{"a_float":{"0":-2.0}}'
'{"a_float":{"0":1.0}}'
'{"a_float":{"0":1.0}}'
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 3.19.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_HK.UTF-8
LOCALE: en_HK.UTF-8
pandas: 0.19.2
nose: 1.3.7
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.3
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.2
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.42.0
pandas_datareader: None