Skip to content

Commit 16bd49d

Browse files
authored
BUG: fix styler cell_ids arg so that blank style is ignored on False (#35588)
1 parent f194094 commit 16bd49d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

doc/source/whatsnew/v1.1.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Fixed regressions
2727
Bug fixes
2828
~~~~~~~~~
2929

30+
- Bug in ``Styler`` whereby `cell_ids` argument had no effect due to other recent changes (:issue:`35588`).
3031

3132
Categorical
3233
^^^^^^^^^^^

pandas/io/formats/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def format_attr(pair):
390390
"is_visible": (c not in hidden_columns),
391391
}
392392
# only add an id if the cell has a style
393-
if self.cell_ids or not (len(ctx[r, c]) == 1 and ctx[r, c][0] == ""):
393+
if self.cell_ids or (r, c) in ctx:
394394
row_dict["id"] = "_".join(cs[1:])
395395
row_es.append(row_dict)
396396
props = []

pandas/tests/io/formats/test_style.py

+6
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,12 @@ def f(a, b, styler):
16821682
result = styler.pipe((f, "styler"), a=1, b=2)
16831683
assert result == (1, 2, styler)
16841684

1685+
def test_no_cell_ids(self):
1686+
# GH 35588
1687+
df = pd.DataFrame(data=[[0]])
1688+
s = Styler(df, uuid="_", cell_ids=False).render()
1689+
assert s.find('<td class="data row0 col0" >') != -1
1690+
16851691

16861692
@td.skip_if_no_mpl
16871693
class TestStylerMatplotlibDep:

0 commit comments

Comments
 (0)