Skip to content

Commit 760c654

Browse files
meeseeksmachineWillAyd
authored andcommitted
Backport PR pandas-dev#28216: REGR: <th> tags for notebook display closes pandas-dev#28204 (pandas-dev#28233)
1 parent c44b555 commit 760c654

9 files changed

+693
-0
lines changed

doc/source/whatsnew/v0.25.2.rst

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Missing
6262
I/O
6363
^^^
6464

65+
- Fix regression in notebook display where <th> tags not used for :attr:`DataFrame.index` (:issue:`28204`).
6566
- Regression in :meth:`~DataFrame.to_csv` where writing a :class:`Series` or :class:`DataFrame` indexed by an :class:`IntervalIndex` would incorrectly raise a ``TypeError`` (:issue:`28210`)
6667
-
6768
-

pandas/core/frame.py

+15
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,25 @@ def _repr_html_(self):
679679

680680
formatter = fmt.DataFrameFormatter(
681681
self,
682+
columns=None,
683+
col_space=None,
684+
na_rep="NaN",
685+
formatters=None,
686+
float_format=None,
687+
sparsify=None,
688+
justify=None,
689+
index_names=True,
690+
header=True,
691+
index=True,
692+
bold_rows=True,
693+
escape=True,
682694
max_rows=max_rows,
683695
min_rows=min_rows,
684696
max_cols=max_cols,
685697
show_dimensions=show_dimensions,
698+
decimal=".",
699+
table_id=None,
700+
render_links=False,
686701
)
687702
formatter.to_html(notebook=True)
688703
return formatter.buf.getvalue()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<div>
2+
<style scoped>
3+
.dataframe tbody tr th:only-of-type {
4+
vertical-align: middle;
5+
}
6+
7+
.dataframe tbody tr th {
8+
vertical-align: top;
9+
}
10+
11+
.dataframe thead th {
12+
text-align: right;
13+
}
14+
</style>
15+
<table border="1" class="dataframe">
16+
<thead>
17+
<tr style="text-align: right;">
18+
<th></th>
19+
<th>a</th>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tr>
24+
<th>0</th>
25+
<td>0</td>
26+
</tr>
27+
<tr>
28+
<th>1</th>
29+
<td>1</td>
30+
</tr>
31+
<tr>
32+
<th>2</th>
33+
<td>2</td>
34+
</tr>
35+
<tr>
36+
<th>3</th>
37+
<td>3</td>
38+
</tr>
39+
<tr>
40+
<th>4</th>
41+
<td>4</td>
42+
</tr>
43+
<tr>
44+
<th>...</th>
45+
<td>...</td>
46+
</tr>
47+
<tr>
48+
<th>56</th>
49+
<td>56</td>
50+
</tr>
51+
<tr>
52+
<th>57</th>
53+
<td>57</td>
54+
</tr>
55+
<tr>
56+
<th>58</th>
57+
<td>58</td>
58+
</tr>
59+
<tr>
60+
<th>59</th>
61+
<td>59</td>
62+
</tr>
63+
<tr>
64+
<th>60</th>
65+
<td>60</td>
66+
</tr>
67+
</tbody>
68+
</table>
69+
<p>61 rows × 1 columns</p>
70+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<div>
2+
<style scoped>
3+
.dataframe tbody tr th:only-of-type {
4+
vertical-align: middle;
5+
}
6+
7+
.dataframe tbody tr th {
8+
vertical-align: top;
9+
}
10+
11+
.dataframe thead th {
12+
text-align: right;
13+
}
14+
</style>
15+
<table border="1" class="dataframe">
16+
<thead>
17+
<tr style="text-align: right;">
18+
<th></th>
19+
<th>a</th>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tr>
24+
<th>0</th>
25+
<td>0</td>
26+
</tr>
27+
<tr>
28+
<th>1</th>
29+
<td>1</td>
30+
</tr>
31+
<tr>
32+
<th>...</th>
33+
<td>...</td>
34+
</tr>
35+
<tr>
36+
<th>59</th>
37+
<td>59</td>
38+
</tr>
39+
<tr>
40+
<th>60</th>
41+
<td>60</td>
42+
</tr>
43+
</tbody>
44+
</table>
45+
<p>61 rows × 1 columns</p>
46+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<div>
2+
<style scoped>
3+
.dataframe tbody tr th:only-of-type {
4+
vertical-align: middle;
5+
}
6+
7+
.dataframe tbody tr th {
8+
vertical-align: top;
9+
}
10+
11+
.dataframe thead th {
12+
text-align: right;
13+
}
14+
</style>
15+
<table border="1" class="dataframe">
16+
<thead>
17+
<tr style="text-align: right;">
18+
<th></th>
19+
<th>a</th>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tr>
24+
<th>0</th>
25+
<td>0</td>
26+
</tr>
27+
<tr>
28+
<th>1</th>
29+
<td>1</td>
30+
</tr>
31+
<tr>
32+
<th>2</th>
33+
<td>2</td>
34+
</tr>
35+
<tr>
36+
<th>3</th>
37+
<td>3</td>
38+
</tr>
39+
<tr>
40+
<th>4</th>
41+
<td>4</td>
42+
</tr>
43+
<tr>
44+
<th>5</th>
45+
<td>5</td>
46+
</tr>
47+
<tr>
48+
<th>...</th>
49+
<td>...</td>
50+
</tr>
51+
<tr>
52+
<th>55</th>
53+
<td>55</td>
54+
</tr>
55+
<tr>
56+
<th>56</th>
57+
<td>56</td>
58+
</tr>
59+
<tr>
60+
<th>57</th>
61+
<td>57</td>
62+
</tr>
63+
<tr>
64+
<th>58</th>
65+
<td>58</td>
66+
</tr>
67+
<tr>
68+
<th>59</th>
69+
<td>59</td>
70+
</tr>
71+
<tr>
72+
<th>60</th>
73+
<td>60</td>
74+
</tr>
75+
</tbody>
76+
</table>
77+
<p>61 rows × 1 columns</p>
78+
</div>

0 commit comments

Comments
 (0)