Skip to content

Commit 6d60064

Browse files
additional test case for pandas-devgh-22783
1 parent 1febf76 commit 6d60064

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<table border="1" class="dataframe">
2+
<thead>
3+
<tr style="text-align: right;">
4+
<th>columns.name</th>
5+
<th>0</th>
6+
<th>1</th>
7+
<th>...</th>
8+
<th>3</th>
9+
<th>4</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<tr>
14+
<th></th>
15+
<td>1.764052</td>
16+
<td>0.400157</td>
17+
<td>...</td>
18+
<td>2.240893</td>
19+
<td>1.867558</td>
20+
</tr>
21+
<tr>
22+
<th></th>
23+
<td>-0.977278</td>
24+
<td>0.950088</td>
25+
<td>...</td>
26+
<td>-0.103219</td>
27+
<td>0.410599</td>
28+
</tr>
29+
</tbody>
30+
</table>
31+

pandas/tests/io/formats/test_to_html.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,20 @@ def test_to_html_truncation_index_false_max_rows(self, datapath, index):
494494
assert result == expected
495495

496496
@pytest.mark.parametrize('index', [False, 0])
497-
def test_to_html_truncation_index_false_max_cols(self, datapath, index):
497+
@pytest.mark.parametrize('col_index_named, expected_output', [
498+
(False, 'gh22783_expected_output'),
499+
(True, 'gh22783_named_columns_index')
500+
])
501+
def test_to_html_truncation_index_false_max_cols(
502+
self, datapath, index, col_index_named, expected_output):
498503
# GH 22783
499504
data = [[1.764052, 0.400157, 0.978738, 2.240893, 1.867558],
500505
[-0.977278, 0.950088, -0.151357, -0.103219, 0.410599]]
501506
df = DataFrame(data)
507+
if col_index_named:
508+
df.columns.rename('columns.name', inplace=True)
502509
result = df.to_html(max_cols=4, index=index)
503-
expected = expected_html(datapath, 'gh22783_expected_output')
510+
expected = expected_html(datapath, expected_output)
504511
assert result == expected
505512

506513
def test_to_html_notebook_has_style(self):

0 commit comments

Comments
 (0)