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

Displayed precision of float in presence of np.inf #24861

glemaitre opened this issue Jan 21, 2019 · 1 comment


None yet
3 participants
Copy link

commented Jan 21, 2019

Code Sample, a copy-pastable example if possible

import numpy as np
import pandas as pd

    pd.Series([1., 2.2222, np.inf]).round(1)

Problem description

The display of floating precision in a dataframe and serie could be improved in the presence of np.inf.
My expectation would be that np.inf would induce the same behavior than 'NaN.

Expected Output

0    1.0
1    2.2
2     inf
dtype: float64

Instead, the following result is obtained:

0    1.000000
1    2.200000
2         inf
dtype: float64

Note that this is the result in presence of a NaN:

0    1.0
1    2.2
2    NaN
dtype: float64

Output of pd.show_versions()

commit: None
python-bits: 64
OS: Linux
OS-release: 4.15.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None

pandas: 0.23.4
pytest: None
pip: 10.0.1
setuptools: 39.2.0
Cython: None
numpy: 1.14.5
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.4.0
sphinx: None
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

This comment has been minimized.

Copy link

commented Jan 21, 2019

Makes sense - investigation and PRs would certainly be welcome

@jorisvandenbossche jorisvandenbossche changed the title Displayed prevision of float in presence of np.inf Displayed precision of float in presence of np.inf Jan 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.