Skip to content

Commit

Permalink
Backport PR #46548: REGR: tests + whats new: boolean dtype in styler …
Browse files Browse the repository at this point in the history
…render (#46577)

Co-authored-by: JHM Darbyshire <24256554+attack68@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and attack68 authored Mar 31, 2022
1 parent 4be9ffd commit 3ff438e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Fixed regressions
- Fixed regression in :meth:`DataFrame.replace` when a replacement value was also a target for replacement (:issue:`46306`)
- Fixed regression in :meth:`DataFrame.replace` when the replacement value was explicitly ``None`` when passed in a dictionary to ``to_replace`` (:issue:`45601`, :issue:`45836`)
- Fixed regression when setting values with :meth:`DataFrame.loc` losing :class:`MultiIndex` names if :class:`DataFrame` was empty before (:issue:`46317`)
-
- Fixed regression when rendering boolean datatype columns with :meth:`.Styler` (:issue:`46384`)

.. ---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/io/formats/style/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,11 @@ def test_1level_multiindex():
assert ctx["body"][0][0]["is_visible"] is True
assert ctx["body"][1][0]["display_value"] == "2"
assert ctx["body"][1][0]["is_visible"] is True


def test_boolean_format():
# gh 46384: booleans do not collapse to integer representation on display
df = DataFrame([[True, False]])
ctx = df.style._translate(True, True)
assert ctx["body"][0][1]["display_value"] is True
assert ctx["body"][0][2]["display_value"] is False

0 comments on commit 3ff438e

Please sign in to comment.