Skip to content

Commit 605a8e8

Browse files
authored
DOC: Example missing in pandas.DataFrame.to_html #44945 (#54153)
1 parent 245db2d commit 605a8e8

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pandas/core/frame.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -3176,8 +3176,29 @@ def to_html(
31763176
31773177
Examples
31783178
--------
3179-
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
3180-
>>> df.to_html() # doctest: +SKIP
3179+
>>> df = pd.DataFrame(data={'col1': [1, 2], 'col2': [4, 3]})
3180+
>>> html_string = '''<table border="1" class="dataframe">
3181+
... <thead>
3182+
... <tr style="text-align: right;">
3183+
... <th></th>
3184+
... <th>col1</th>
3185+
... <th>col2</th>
3186+
... </tr>
3187+
... </thead>
3188+
... <tbody>
3189+
... <tr>
3190+
... <th>0</th>
3191+
... <td>1</td>
3192+
... <td>4</td>
3193+
... </tr>
3194+
... <tr>
3195+
... <th>1</th>
3196+
... <td>2</td>
3197+
... <td>3</td>
3198+
... </tr>
3199+
... </tbody>
3200+
... </table>'''
3201+
>>> assert html_string == df.to_html()
31813202
"""
31823203
if justify is not None and justify not in fmt._VALID_JUSTIFY_PARAMETERS:
31833204
raise ValueError("Invalid value for justify parameter")

0 commit comments

Comments
 (0)