Skip to content

Commit 426565e

Browse files
committed
BUG: fix for bug 16493
1 parent a40820d commit 426565e

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ I/O
5959
- Bug in pd.read_csv() when comment is passed in space deliminted text files (:issue:`16472`)
6060
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)
6161
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`)
62+
- Bug where to_html ignored the index_names parameter (:issue:`16493`)
6263

6364

6465
Plotting

pandas/io/formats/format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ def _column_header():
12921292
self.write_tr(col_row, indent, self.indent_delta, header=True,
12931293
align=align)
12941294

1295-
if self.fmt.has_index_names and self.fmt.index and self.show_index_names:
1295+
if self.fmt.has_index_names and self.fmt.index and self.fmt.show_index_names:
12961296
row = ([x if x is not None else ''
12971297
for x in self.frame.index.names] +
12981298
[''] * min(len(self.columns), self.max_cols))

pandas/tests/io/formats/test_to_html.py

+5
Original file line numberDiff line numberDiff line change
@@ -1869,3 +1869,8 @@ def test_to_html_notebook_has_no_style(self):
18691869
df = pd.DataFrame({"A": [1, 2, 3]})
18701870
result = df.to_html()
18711871
assert "thead tr:only-child" not in result
1872+
1873+
def test_to_html_with_index_names_false(self):
1874+
df = pd.DataFrame({"A": [1, 2], index=pd.Index(['a', 'b'], name='myindexname'})
1875+
result = df.to_html(index_names=False)
1876+
assert 'myindexname' not in result

0 commit comments

Comments
 (0)