Skip to content

Commit 9e3b8df

Browse files
authored
CLN: w3 formatting (#36223)
1 parent 7d16224 commit 9e3b8df

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/io/formats/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def format_attr(pair):
327327
colspan = col_lengths.get((r, c), 0)
328328
if colspan > 1:
329329
es["attributes"] = [
330-
format_attr({"key": "colspan", "value": colspan})
330+
format_attr({"key": "colspan", "value": f'"{colspan}"'})
331331
]
332332
row_es.append(es)
333333
head.append(row_es)

pandas/tests/io/formats/test_style.py

+6
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,12 @@ def test_no_cell_ids(self):
16911691
s = styler.render() # render twice to ensure ctx is not updated
16921692
assert s.find('<td class="data row0 col0" >') != -1
16931693

1694+
def test_colspan_w3(self):
1695+
# GH 36223
1696+
df = pd.DataFrame(data=[[1, 2]], columns=[["l0", "l0"], ["l1a", "l1b"]])
1697+
s = Styler(df, uuid="_", cell_ids=False)
1698+
assert '<th class="col_heading level0 col0" colspan="2">l0</th>' in s.render()
1699+
16941700

16951701
@td.skip_if_no_mpl
16961702
class TestStylerMatplotlibDep:

0 commit comments

Comments
 (0)