Skip to content

Backport PR #28216 on branch 0.25.x (REGR: <th> tags for notebook display closes #28204) #28233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Missing
I/O
^^^

- Fix regression in notebook display where <th> tags not used for :attr:`DataFrame.index` (:issue:`28204`).
- 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`)
-
-
Expand Down
15 changes: 15 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,25 @@ def _repr_html_(self):

formatter = fmt.DataFrameFormatter(
self,
columns=None,
col_space=None,
na_rep="NaN",
formatters=None,
float_format=None,
sparsify=None,
justify=None,
index_names=True,
header=True,
index=True,
bold_rows=True,
escape=True,
max_rows=max_rows,
min_rows=min_rows,
max_cols=max_cols,
show_dimensions=show_dimensions,
decimal=".",
table_id=None,
render_links=False,
)
formatter.to_html(notebook=True)
return formatter.buf.getvalue()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}

.dataframe tbody tr th {
vertical-align: top;
}

.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>a</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0</td>
</tr>
<tr>
<th>1</th>
<td>1</td>
</tr>
<tr>
<th>2</th>
<td>2</td>
</tr>
<tr>
<th>3</th>
<td>3</td>
</tr>
<tr>
<th>4</th>
<td>4</td>
</tr>
<tr>
<th>...</th>
<td>...</td>
</tr>
<tr>
<th>56</th>
<td>56</td>
</tr>
<tr>
<th>57</th>
<td>57</td>
</tr>
<tr>
<th>58</th>
<td>58</td>
</tr>
<tr>
<th>59</th>
<td>59</td>
</tr>
<tr>
<th>60</th>
<td>60</td>
</tr>
</tbody>
</table>
<p>61 rows × 1 columns</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}

.dataframe tbody tr th {
vertical-align: top;
}

.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>a</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0</td>
</tr>
<tr>
<th>1</th>
<td>1</td>
</tr>
<tr>
<th>...</th>
<td>...</td>
</tr>
<tr>
<th>59</th>
<td>59</td>
</tr>
<tr>
<th>60</th>
<td>60</td>
</tr>
</tbody>
</table>
<p>61 rows × 1 columns</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}

.dataframe tbody tr th {
vertical-align: top;
}

.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>a</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0</td>
</tr>
<tr>
<th>1</th>
<td>1</td>
</tr>
<tr>
<th>2</th>
<td>2</td>
</tr>
<tr>
<th>3</th>
<td>3</td>
</tr>
<tr>
<th>4</th>
<td>4</td>
</tr>
<tr>
<th>5</th>
<td>5</td>
</tr>
<tr>
<th>...</th>
<td>...</td>
</tr>
<tr>
<th>55</th>
<td>55</td>
</tr>
<tr>
<th>56</th>
<td>56</td>
</tr>
<tr>
<th>57</th>
<td>57</td>
</tr>
<tr>
<th>58</th>
<td>58</td>
</tr>
<tr>
<th>59</th>
<td>59</td>
</tr>
<tr>
<th>60</th>
<td>60</td>
</tr>
</tbody>
</table>
<p>61 rows × 1 columns</p>
</div>
Loading