Skip to content

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

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

Closed
glemaitre opened this issue Jan 21, 2019 · 1 comment · Fixed by #24863
Closed

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

glemaitre opened this issue Jan 21, 2019 · 1 comment · Fixed by #24863
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string

Comments

@glemaitre
Copy link
Contributor

Code Sample, a copy-pastable example if possible

import numpy as np
import pandas as pd

print(
    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()

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

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
@jschendel jschendel added Bug Output-Formatting __repr__ of pandas objects, to_string labels Jan 21, 2019
@WillAyd WillAyd added this to the Contributions Welcome milestone Jan 21, 2019
@WillAyd
Copy link
Member

WillAyd 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
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants