question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Styler renders booleans True/False as digits since 1.4.0

See original GitHub issue

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

d = {
    "species": ["parrot", "dodo", "moa", "whale"],
    "extinct": [False, True, True, False],
}
df = pd.DataFrame(data=d)
print(df.head())
print(df.dtypes)


def applyStyle(df):
    style = [
        dict(
            selector="th",
            props=[
                ("font-size", "100%"),
                ("text-align", "left"),
                ("text-transform", "capitalize"),
                ("background-color", "#333399"),
                ("color", "white"),
            ],
        ),
        dict(selector="caption", props=[("caption-side", "bottom")]),
        dict(selector="td a", props=[("display", "block")]),
    ]
    patchingStyle = (
        df.style.set_table_styles(style)
        .set_properties(subset=["species"], **{"width": "200px"})
        .set_properties(subset=["extinct"], **{"width": "130px"})  
    )
    return patchingStyle


html = applyStyle(df).to_html(doctype_html=True)
with open("test.html", "w", encoding="utf-8") as f:
    f.write(html)

Issue Description

Datatype boolean in dataframe is now rendered as digits when passed to styler since version 1.4.0

species extinct 0 parrot False 1 dodo True 2 moa True 3 whale False species object extinct bool dtype: object Screenshot 2022-03-16 at 00 11 04

Expected Behavior

species extinct 0 parrot False 1 dodo True 2 moa True 3 whale False species object extinct bool dtype: object Screenshot 2022-03-16 at 00 08 18

Installed Versions

INSTALLED VERSIONS

commit : 06d230151e6f18fdb8139d09abf539867a8cd481 python : 3.9.5.final.0 python-bits : 64 OS : Darwin OS-release : 19.6.0 Version : Darwin Kernel Version 19.6.0: Thu Jan 13 01:26:33 PST 2022; root:xnu-6153.141.51~3/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_GB.UTF-8 LOCALE : en_GB.UTF-8

pandas : 1.4.1 numpy : 1.20.3 pytz : 2021.1 dateutil : 2.8.1 pip : 22.0.4 setuptools : 56.0.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.0.1 IPython : 7.24.1 pandas_datareader: None bs4 : None bottleneck : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.4.2 numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : 1.6.3 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
simonjayhawkinscommented, Mar 25, 2022

Datatype boolean in dataframe is now rendered as digits when passed to styler since version 1.4.0

can confirm regression from 1.3.5

first bad commit: [08ac29ab685d5e488a5b122944f8ee2f5000b6c9] ENH: styler.format options (#43256)

0reactions
simonjayhawkinscommented, Mar 25, 2022

I believe it is #46119.

can confirm, reverting #46119 results in code sample in https://github.com/pandas-dev/pandas/issues/46384#issuecomment-1068786611 giving same result as 1.4.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's new in 1.4.0 (January 22, 2022) — pandas 1.5.1 ...
Styling and formatting of indexes has been added, with Styler. · The new method Styler. · The keyword arguments level and names have...
Read more >
estimagic.visualization.estimation_table — estimagic 0.4.3.dev0 ...
The default is None. show_col_names (bool): If True, the column names are ... If True, format floats such that they have same number...
Read more >
Expressions | Style Specification | Mapbox GL JS - Mapbox docs
Learn how to write expressions in Mapbox GL JS to style custom data based on a data ... If the input is a...
Read more >
Command Line Usage - Less CSS
When false, URLs are already relative to the entry less file. useFileCache. Type: Boolean. Default: true (previously false in before v2). Whether to...
Read more >
NatTable 1.4.0 - New & Noteworthy | The Eclipse Foundation
CSS property to specify whether text should be trimmed on rendering words or not. Default is true. Available values: true, false. validation-error-background- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found