Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 817a438

Browse files
committed
add dataframe class to table
1 parent 214969d commit 817a438

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

bigframes/display/html.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def render_html(
3535
table_id: str,
3636
) -> str:
3737
"""Render a pandas DataFrame to HTML with specific styling."""
38-
classes = "table table-striped table-hover"
38+
classes = "dataframe table table-striped table-hover"
3939
table_html = [f'<table border="1" class="{classes}" id="{table_id}">']
4040
precision = options.display.precision
4141

@@ -50,14 +50,16 @@ def render_html(
5050
table_html.append(" </thead>")
5151

5252
# Render table body
53-
table_html.append(' <tbody style="padding: 0.5em;">')
53+
table_html.append(" <tbody>")
5454
for i in range(len(dataframe)):
5555
table_html.append(" <tr>")
5656
row = dataframe.iloc[i]
5757
for col_name, value in row.items():
5858
dtype = dataframe.dtypes.loc[col_name] # type: ignore
5959
align = "right" if _is_dtype_numeric(dtype) else "left"
60-
table_html.append(' <td style="text-align: {};">'.format(align))
60+
table_html.append(
61+
' <td style="text-align: {}; padding: 0.5em;">'.format(align)
62+
)
6163

6264
# TODO(b/438181139): Consider semi-exploding ARRAY/STRUCT columns
6365
# into multiple rows/columns like the BQ UI does.

tests/unit/display/test_html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_render_html_alignment_and_precision(
132132

133133
for _, align in expected_alignments.items():
134134
assert 'th style="text-align: left;"' in html
135-
assert f'<td style="text-align: {align};">' in html
135+
assert f'<td style="text-align: {align};' in html
136136

137137
for expected_string in expected_strings:
138138
assert expected_string in html

0 commit comments

Comments
 (0)