Skip to content

to_html formatter not called for float values in a mixed-type column #13021

Open
@patricksurry

Description

@patricksurry

When column x has float64 type, the custom formatter is applied to every value

t = pd.DataFrame([[0], [10.4], [3]], columns=['x'])
display(HTML(t.to_html(formatters=dict(x='xxx'.format))))

   x
------
0  xxx
1  xxx
2  xxx

But when column x is mixed type, the formatter isn't called for (only) floating point values

t = pd.DataFrame([['a'], [0], [10.4], [3]], columns=['x'])
display(HTML(t.to_html(formatters=dict(x='xxx'.format))))

   x
------
0  xxx
1  xxx
2  10.4
3  xxx

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0
nose: None
pip: 1.5.4
setuptools: 20.7.0
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: None
boto: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO HTMLread_html, to_html, Styler.apply, Styler.applymap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions