We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
import pandas as pd print(pd.DataFrame([100.0]).to_html(float_format='%.0f'))
The above code will render a value of 1 instead of 100.
<table border="1" class="dataframe"> ... <td>1</td> ... </table>
<table border="1" class="dataframe"> ... <td>100</td> ... </table>
pd.show_versions()
commit: None python: 2.7.5.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-123.20.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: None.None
pandas: 0.23.4 pytest: None pip: 18.0 setuptools: 39.1.0 Cython: 0.23.4 numpy: 1.14.0 scipy: 1.0.0 pyarrow: 0.9.0 xarray: None IPython: 5.6.0 sphinx: None patsy: 0.5.0 dateutil: 2.6.1 pytz: 2018.3 blosc: None bottleneck: None tables: 3.4.2 numexpr: 2.6.2 feather: 0.4.0 matplotlib: 1.4.3 openpyxl: 2.4.9 xlrd: 0.9.3 xlwt: 1.0.0 xlsxwriter: 0.9.6 lxml: 3.4.2 bs4: 4.6.0 html5lib: 1.0.1 sqlalchemy: 1.0.12 pymysql: None psycopg2: 2.6.1 (dt dec pq3 ext) jinja2: 2.8 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
The text was updated successfully, but these errors were encountered:
DataFrame.to_string() is also affected. It seems that _trim_zeros causes the problem pandas/io/formats/format.py+1053:
class FloatArrayFormatter(GenericArrayFormatter): ... def get_result_as_array(self): ... def format_values_with(float_format): ... if self.fixed_width: return _trim_zeros(values, self.na_rep)
Sorry, something went wrong.
Changing the default value of "fixed_width" argument of GenericArrayFormatter to False solves the problem, but may cause others.
This may be related to the discussion in #21625 and potentially solved by the PR quoted at the end of that thread.
@tomneep since you made that commit - any interest in packaging that up with tests in a PR to see if we can knock both of these issues out?
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
Problem description
The above code will render a value of 1 instead of 100.
Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS [0/1850]
commit: None
python: 2.7.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.10.0-123.20.1.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.23.4
pytest: None
pip: 18.0
setuptools: 39.1.0
Cython: 0.23.4
numpy: 1.14.0
scipy: 1.0.0
pyarrow: 0.9.0
xarray: None
IPython: 5.6.0
sphinx: None
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: 0.4.0
matplotlib: 1.4.3
openpyxl: 2.4.9
xlrd: 0.9.3
xlwt: 1.0.0
xlsxwriter: 0.9.6
lxml: 3.4.2
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.0.12
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext)
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: