diff --git a/doc/source/whatsnew/v0.24.0.rst b/doc/source/whatsnew/v0.24.0.rst
index 8c686db22299b2..1fe5e4e6e70871 100644
--- a/doc/source/whatsnew/v0.24.0.rst
+++ b/doc/source/whatsnew/v0.24.0.rst
@@ -1596,6 +1596,8 @@ Notice how we now instead output ``np.nan`` itself instead of a stringified form
- :func:`read_sas()` will correctly parse sas7bdat files with data page types having also bit 7 set (so page type is 128 + 256 = 384) (:issue:`16615`)
- Bug in :meth:`detect_client_encoding` where potential ``IOError`` goes unhandled when importing in a mod_wsgi process due to restricted access to stdout. (:issue:`21552`)
- Bug in :func:`to_html()` with ``index=False`` misses truncation indicators (...) on truncated DataFrame (:issue:`15019`, :issue:`22783`)
+- Bug in :func:`to_html()` with ``index=False`` when both columns and row index are ``MultiIndex`` (:issue:`22579`)
+- Bug in :func:`to_html()` with ``index_names=False`` displaying index name (:issue:`22747`)
- Bug in :func:`DataFrame.to_string()` that broke column alignment when ``index=False`` and width of first column's values is greater than the width of first column's header (:issue:`16839`, :issue:`13032`)
- Bug in :func:`DataFrame.to_string()` that caused representations of :class:`DataFrame` to not take up the whole window (:issue:`22984`)
- Bug in :func:`DataFrame.to_csv` where a single level MultiIndex incorrectly wrote a tuple. Now just the value of the index is written (:issue:`19589`).
diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py
index cac0c699d70468..eb11dd461927b4 100644
--- a/pandas/io/formats/html.py
+++ b/pandas/io/formats/html.py
@@ -43,6 +43,35 @@ def __init__(self, formatter, classes=None, notebook=False, border=None,
self.table_id = table_id
self.render_links = render_links
+ @property
+ def show_col_idx_names(self):
+ # see gh-22579
+ # Column misalignment also occurs for
+ # a standard index when the columns index is named.
+ # Determine if ANY column names need to be displayed
+ # since if the row index is not displayed a column of
+ # blank cells need to be included before the DataFrame values.
+ # TODO: refactor to add show_col_idx_names property to
+ # DataFrameFormatter
+ return all((self.fmt.has_column_names,
+ self.fmt.show_index_names,
+ self.fmt.header))
+
+ @property
+ def row_levels(self):
+ if self.fmt.index:
+ # showing (row) index
+ return self.frame.index.nlevels
+ elif self.show_col_idx_names:
+ # see gh-22579
+ # Column misalignment also occurs for
+ # a standard index when the columns index is named.
+ # If the row index is not displayed a column of
+ # blank cells need to be included before the DataFrame values.
+ return 1
+ # not showing (row) index
+ return 0
+
@property
def is_truncated(self):
return self.fmt.is_truncated
@@ -201,7 +230,7 @@ def write_result(self, buf):
def _write_header(self, indent):
truncate_h = self.fmt.truncate_h
- row_levels = self.frame.index.nlevels
+
if not self.fmt.header:
# write nothing
return indent
@@ -267,12 +296,26 @@ def _write_header(self, indent):
values = (values[:ins_col] + [u('...')] +
values[ins_col:])
- name = self.columns.names[lnum]
- row = [''] * (row_levels - 1) + ['' if name is None else
- pprint_thing(name)]
-
- if row == [""] and self.fmt.index is False:
- row = []
+ # see gh-22579
+ # Column Offset Bug with to_html(index=False) with
+ # MultiIndex Columns and Index.
+ # Initially fill row with blank cells before column names.
+ # TODO: Refactor to remove code duplication with code
+ # block below for standard columns index.
+ row = [''] * (self.row_levels - 1)
+ if self.fmt.index or self.show_col_idx_names:
+ # see gh-22747
+ # If to_html(index_names=False) do not show columns
+ # index names.
+ # TODO: Refactor to use _get_column_name_list from
+ # DataFrameFormatter class and create a
+ # _get_formatted_column_labels function for code
+ # parity with DataFrameFormatter class.
+ if self.fmt.show_index_names:
+ name = self.columns.names[lnum]
+ row.append(pprint_thing(name or ''))
+ else:
+ row.append('')
tags = {}
j = len(row)
@@ -287,18 +330,28 @@ def _write_header(self, indent):
self.write_tr(row, indent, self.indent_delta, tags=tags,
header=True)
else:
- if self.fmt.index:
- row = [''] * (self.frame.index.nlevels - 1)
- row.append(self.columns.name or '')
- else:
- row = []
+ # see gh-22579
+ # Column misalignment also occurs for
+ # a standard index when the columns index is named.
+ # Initially fill row with blank cells before column names.
+ # TODO: Refactor to remove code duplication with code block
+ # above for columns MultiIndex.
+ row = [''] * (self.row_levels - 1)
+ if self.fmt.index or self.show_col_idx_names:
+ # see gh-22747
+ # If to_html(index_names=False) do not show columns
+ # index names.
+ # TODO: Refactor to use _get_column_name_list from
+ # DataFrameFormatter class.
+ if self.fmt.show_index_names:
+ row.append(self.columns.name or '')
+ else:
+ row.append('')
row.extend(self.columns)
align = self.fmt.justify
if truncate_h:
- if not self.fmt.index:
- row_levels = 0
- ins_col = row_levels + self.fmt.tr_col_num
+ ins_col = self.row_levels + self.fmt.tr_col_num
row.insert(ins_col, '...')
self.write_tr(row, indent, self.indent_delta, header=True,
@@ -346,9 +399,6 @@ def _write_regular_rows(self, fmt_values, indent):
index_values = self.fmt.tr_frame.index.map(fmt)
else:
index_values = self.fmt.tr_frame.index.format()
- row_levels = 1
- else:
- row_levels = 0
row = []
for i in range(nrows):
@@ -356,18 +406,24 @@ def _write_regular_rows(self, fmt_values, indent):
if truncate_v and i == (self.fmt.tr_row_num):
str_sep_row = ['...'] * len(row)
self.write_tr(str_sep_row, indent, self.indent_delta,
- tags=None, nindex_levels=row_levels)
+ tags=None, nindex_levels=self.row_levels)
row = []
if self.fmt.index:
row.append(index_values[i])
+ # see gh-22579
+ # Column misalignment also occurs for
+ # a standard index when the columns index is named.
+ # Add blank cell before data cells.
+ elif self.show_col_idx_names:
+ row.append('')
row.extend(fmt_values[j][i] for j in range(self.ncols))
if truncate_h:
- dot_col_ix = self.fmt.tr_col_num + row_levels
+ dot_col_ix = self.fmt.tr_col_num + self.row_levels
row.insert(dot_col_ix, '...')
self.write_tr(row, indent, self.indent_delta, tags=None,
- nindex_levels=row_levels)
+ nindex_levels=self.row_levels)
def _write_hierarchical_rows(self, fmt_values, indent):
template = 'rowspan="{span}" valign="top"'
@@ -376,6 +432,8 @@ def _write_hierarchical_rows(self, fmt_values, indent):
truncate_v = self.fmt.truncate_v
frame = self.fmt.tr_frame
nrows = len(frame)
+ # TODO: after gh-22887 fixed, refactor to use class property
+ # in place of row_levels
row_levels = self.frame.index.nlevels
idx_values = frame.index.format(sparsify=False, adjoin=False,
diff --git a/pandas/tests/io/formats/data/datetime64_hourformatter.html b/pandas/tests/io/formats/data/html/datetime64_hourformatter.html
similarity index 100%
rename from pandas/tests/io/formats/data/datetime64_hourformatter.html
rename to pandas/tests/io/formats/data/html/datetime64_hourformatter.html
diff --git a/pandas/tests/io/formats/data/datetime64_monthformatter.html b/pandas/tests/io/formats/data/html/datetime64_monthformatter.html
similarity index 100%
rename from pandas/tests/io/formats/data/datetime64_monthformatter.html
rename to pandas/tests/io/formats/data/html/datetime64_monthformatter.html
diff --git a/pandas/tests/io/formats/data/escape_disabled.html b/pandas/tests/io/formats/data/html/escape_disabled.html
similarity index 100%
rename from pandas/tests/io/formats/data/escape_disabled.html
rename to pandas/tests/io/formats/data/html/escape_disabled.html
diff --git a/pandas/tests/io/formats/data/escaped.html b/pandas/tests/io/formats/data/html/escaped.html
similarity index 100%
rename from pandas/tests/io/formats/data/escaped.html
rename to pandas/tests/io/formats/data/html/escaped.html
diff --git a/pandas/tests/io/formats/data/gh12031_expected_output.html b/pandas/tests/io/formats/data/html/gh12031_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh12031_expected_output.html
rename to pandas/tests/io/formats/data/html/gh12031_expected_output.html
diff --git a/pandas/tests/io/formats/data/gh14882_expected_output_1.html b/pandas/tests/io/formats/data/html/gh14882_expected_output_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh14882_expected_output_1.html
rename to pandas/tests/io/formats/data/html/gh14882_expected_output_1.html
diff --git a/pandas/tests/io/formats/data/gh14882_expected_output_2.html b/pandas/tests/io/formats/data/html/gh14882_expected_output_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh14882_expected_output_2.html
rename to pandas/tests/io/formats/data/html/gh14882_expected_output_2.html
diff --git a/pandas/tests/io/formats/data/gh14998_expected_output.html b/pandas/tests/io/formats/data/html/gh14998_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh14998_expected_output.html
rename to pandas/tests/io/formats/data/html/gh14998_expected_output.html
diff --git a/pandas/tests/io/formats/data/gh15019_expected_output.html b/pandas/tests/io/formats/data/html/gh15019_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh15019_expected_output.html
rename to pandas/tests/io/formats/data/html/gh15019_expected_output.html
diff --git a/pandas/tests/io/formats/data/gh21625_expected_output.html b/pandas/tests/io/formats/data/html/gh21625_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh21625_expected_output.html
rename to pandas/tests/io/formats/data/html/gh21625_expected_output.html
diff --git a/pandas/tests/io/formats/data/gh22270_expected_output.html b/pandas/tests/io/formats/data/html/gh22270_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh22270_expected_output.html
rename to pandas/tests/io/formats/data/html/gh22270_expected_output.html
diff --git a/pandas/tests/io/formats/data/html/gh22579_expected_output.html b/pandas/tests/io/formats/data/html/gh22579_expected_output.html
new file mode 100644
index 00000000000000..425b0f915ed16e
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/gh22579_expected_output.html
@@ -0,0 +1,76 @@
+
+
+
+ a |
+ b |
+
+
+ c |
+ d |
+ c |
+ d |
+
+
+
+
+ 0 |
+ 10 |
+ 10 |
+ 10 |
+
+
+ 1 |
+ 11 |
+ 11 |
+ 11 |
+
+
+ 2 |
+ 12 |
+ 12 |
+ 12 |
+
+
+ 3 |
+ 13 |
+ 13 |
+ 13 |
+
+
+ 4 |
+ 14 |
+ 14 |
+ 14 |
+
+
+ 5 |
+ 15 |
+ 15 |
+ 15 |
+
+
+ 6 |
+ 16 |
+ 16 |
+ 16 |
+
+
+ 7 |
+ 17 |
+ 17 |
+ 17 |
+
+
+ 8 |
+ 18 |
+ 18 |
+ 18 |
+
+
+ 9 |
+ 19 |
+ 19 |
+ 19 |
+
+
+
diff --git a/pandas/tests/io/formats/data/gh22783_expected_output.html b/pandas/tests/io/formats/data/html/gh22783_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh22783_expected_output.html
rename to pandas/tests/io/formats/data/html/gh22783_expected_output.html
diff --git a/pandas/tests/io/formats/data/html/gh22783_named_columns_index.html b/pandas/tests/io/formats/data/html/gh22783_named_columns_index.html
new file mode 100644
index 00000000000000..55ab290920cc5b
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/gh22783_named_columns_index.html
@@ -0,0 +1,30 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 3 |
+ 4 |
+
+
+
+
+ |
+ 1.764052 |
+ 0.400157 |
+ ... |
+ 2.240893 |
+ 1.867558 |
+
+
+ |
+ -0.977278 |
+ 0.950088 |
+ ... |
+ -0.103219 |
+ 0.410599 |
+
+
+
diff --git a/pandas/tests/io/formats/data/gh6131_expected_output.html b/pandas/tests/io/formats/data/html/gh6131_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh6131_expected_output.html
rename to pandas/tests/io/formats/data/html/gh6131_expected_output.html
diff --git a/pandas/tests/io/formats/data/gh8452_expected_output.html b/pandas/tests/io/formats/data/html/gh8452_expected_output.html
similarity index 100%
rename from pandas/tests/io/formats/data/gh8452_expected_output.html
rename to pandas/tests/io/formats/data/html/gh8452_expected_output.html
diff --git a/pandas/tests/io/formats/data/index_1.html b/pandas/tests/io/formats/data/html/index_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_1.html
rename to pandas/tests/io/formats/data/html/index_1.html
diff --git a/pandas/tests/io/formats/data/index_2.html b/pandas/tests/io/formats/data/html/index_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_2.html
rename to pandas/tests/io/formats/data/html/index_2.html
diff --git a/pandas/tests/io/formats/data/index_3.html b/pandas/tests/io/formats/data/html/index_3.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_3.html
rename to pandas/tests/io/formats/data/html/index_3.html
diff --git a/pandas/tests/io/formats/data/index_4.html b/pandas/tests/io/formats/data/html/index_4.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_4.html
rename to pandas/tests/io/formats/data/html/index_4.html
diff --git a/pandas/tests/io/formats/data/index_5.html b/pandas/tests/io/formats/data/html/index_5.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_5.html
rename to pandas/tests/io/formats/data/html/index_5.html
diff --git a/pandas/tests/io/formats/data/index_formatter.html b/pandas/tests/io/formats/data/html/index_formatter.html
similarity index 100%
rename from pandas/tests/io/formats/data/index_formatter.html
rename to pandas/tests/io/formats/data/html/index_formatter.html
diff --git a/pandas/tests/io/formats/data/html/index_named_multi_columns_named_multi.html b/pandas/tests/io/formats/data/html/index_named_multi_columns_named_multi.html
new file mode 100644
index 00000000000000..817b54d77f8b12
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_multi_columns_named_multi.html
@@ -0,0 +1,34 @@
+
+
+
+ |
+ columns.name.0 |
+ a |
+
+
+ |
+ columns.name.1 |
+ b |
+ c |
+
+
+ index.name.0 |
+ index.name.1 |
+ |
+ |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_multi_columns_named_standard.html b/pandas/tests/io/formats/data/html/index_named_multi_columns_named_standard.html
new file mode 100644
index 00000000000000..e85965f14075de
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_multi_columns_named_standard.html
@@ -0,0 +1,29 @@
+
+
+
+ |
+ columns.name |
+ 0 |
+ 1 |
+
+
+ index.name.0 |
+ index.name.1 |
+ |
+ |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..7af63e893b12e5
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_multi.html
@@ -0,0 +1,34 @@
+
+
+
+ |
+ |
+ a |
+
+
+ |
+ |
+ b |
+ c |
+
+
+ index.name.0 |
+ index.name.1 |
+ |
+ |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..2f7837864bf885
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_multi_columns_unnamed_standard.html
@@ -0,0 +1,29 @@
+
+
+
+ |
+ |
+ 0 |
+ 1 |
+
+
+ index.name.0 |
+ index.name.1 |
+ |
+ |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_standard_columns_named_multi.html b/pandas/tests/io/formats/data/html/index_named_standard_columns_named_multi.html
new file mode 100644
index 00000000000000..ca9b8bd834a9c6
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_standard_columns_named_multi.html
@@ -0,0 +1,30 @@
+
+
+
+ columns.name.0 |
+ a |
+
+
+ columns.name.1 |
+ b |
+ c |
+
+
+ index.name |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_standard_columns_named_standard.html b/pandas/tests/io/formats/data/html/index_named_standard_columns_named_standard.html
new file mode 100644
index 00000000000000..6478c99ad85e91
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_standard_columns_named_standard.html
@@ -0,0 +1,26 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+
+
+ index.name |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..d7660872177dc1
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_multi.html
@@ -0,0 +1,30 @@
+
+
+
+ |
+ a |
+
+
+ |
+ b |
+ c |
+
+
+ index.name |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..4810f66018d3b7
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_named_standard_columns_unnamed_standard.html
@@ -0,0 +1,26 @@
+
+
+
+ |
+ 0 |
+ 1 |
+
+
+ index.name |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_none_columns_named_multi.html b/pandas/tests/io/formats/data/html/index_none_columns_named_multi.html
new file mode 100644
index 00000000000000..e111f55be7d251
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_none_columns_named_multi.html
@@ -0,0 +1,25 @@
+
+
+
+ columns.name.0 |
+ a |
+
+
+ columns.name.1 |
+ b |
+ c |
+
+
+
+
+ |
+ 0 |
+ 0 |
+
+
+ |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_none_columns_named_standard.html b/pandas/tests/io/formats/data/html/index_none_columns_named_standard.html
new file mode 100644
index 00000000000000..d3a9ba017b43ed
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_none_columns_named_standard.html
@@ -0,0 +1,21 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+
+
+
+
+ |
+ 0 |
+ 0 |
+
+
+ |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_none_columns_none.html b/pandas/tests/io/formats/data/html/index_none_columns_none.html
new file mode 100644
index 00000000000000..44899858d95196
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_none_columns_none.html
@@ -0,0 +1,12 @@
+
+
+
+ 0 |
+ 0 |
+
+
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_none_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/index_none_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..b21a618328b1b8
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_none_columns_unnamed_multi.html
@@ -0,0 +1,21 @@
+
+
+
+ a |
+
+
+ b |
+ c |
+
+
+
+
+ 0 |
+ 0 |
+
+
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_none_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/index_none_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..1249fa56050998
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_none_columns_unnamed_standard.html
@@ -0,0 +1,18 @@
+
+
+
+ 0 |
+ 1 |
+
+
+
+
+ 0 |
+ 0 |
+
+
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_multi.html b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_multi.html
new file mode 100644
index 00000000000000..95c38c9c8fd281
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_multi.html
@@ -0,0 +1,28 @@
+
+
+
+ |
+ columns.name.0 |
+ a |
+
+
+ |
+ columns.name.1 |
+ b |
+ c |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_standard.html b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_standard.html
new file mode 100644
index 00000000000000..9583a21f55f014
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_named_standard.html
@@ -0,0 +1,23 @@
+
+
+
+ |
+ columns.name |
+ 0 |
+ 1 |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..f620259037b60c
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_multi.html
@@ -0,0 +1,28 @@
+
+
+
+ |
+ |
+ a |
+
+
+ |
+ |
+ b |
+ c |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..2ca18c288437be
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_multi_columns_unnamed_standard.html
@@ -0,0 +1,23 @@
+
+
+
+ |
+ |
+ 0 |
+ 1 |
+
+
+
+
+ a |
+ b |
+ 0 |
+ 0 |
+
+
+ c |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_multi.html b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_multi.html
new file mode 100644
index 00000000000000..ed3360f898afd7
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_multi.html
@@ -0,0 +1,25 @@
+
+
+
+ columns.name.0 |
+ a |
+
+
+ columns.name.1 |
+ b |
+ c |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_standard.html b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_standard.html
new file mode 100644
index 00000000000000..54da03858a9a4a
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_named_standard.html
@@ -0,0 +1,21 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..b57fafbe0ca40d
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_multi.html
@@ -0,0 +1,25 @@
+
+
+
+ |
+ a |
+
+
+ |
+ b |
+ c |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..235ca61a9e63d4
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/index_unnamed_standard_columns_unnamed_standard.html
@@ -0,0 +1,21 @@
+
+
+
+ |
+ 0 |
+ 1 |
+
+
+
+
+ 0 |
+ 0 |
+ 0 |
+
+
+ 1 |
+ 0 |
+ 0 |
+
+
+
diff --git a/pandas/tests/io/formats/data/justify.html b/pandas/tests/io/formats/data/html/justify.html
similarity index 100%
rename from pandas/tests/io/formats/data/justify.html
rename to pandas/tests/io/formats/data/html/justify.html
diff --git a/pandas/tests/io/formats/data/multiindex_1.html b/pandas/tests/io/formats/data/html/multiindex_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_1.html
rename to pandas/tests/io/formats/data/html/multiindex_1.html
diff --git a/pandas/tests/io/formats/data/multiindex_2.html b/pandas/tests/io/formats/data/html/multiindex_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_2.html
rename to pandas/tests/io/formats/data/html/multiindex_2.html
diff --git a/pandas/tests/io/formats/data/multiindex_sparsify_1.html b/pandas/tests/io/formats/data/html/multiindex_sparsify_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_sparsify_1.html
rename to pandas/tests/io/formats/data/html/multiindex_sparsify_1.html
diff --git a/pandas/tests/io/formats/data/multiindex_sparsify_2.html b/pandas/tests/io/formats/data/html/multiindex_sparsify_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_sparsify_2.html
rename to pandas/tests/io/formats/data/html/multiindex_sparsify_2.html
diff --git a/pandas/tests/io/formats/data/multiindex_sparsify_false_multi_sparse_1.html b/pandas/tests/io/formats/data/html/multiindex_sparsify_false_multi_sparse_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_sparsify_false_multi_sparse_1.html
rename to pandas/tests/io/formats/data/html/multiindex_sparsify_false_multi_sparse_1.html
diff --git a/pandas/tests/io/formats/data/multiindex_sparsify_false_multi_sparse_2.html b/pandas/tests/io/formats/data/html/multiindex_sparsify_false_multi_sparse_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/multiindex_sparsify_false_multi_sparse_2.html
rename to pandas/tests/io/formats/data/html/multiindex_sparsify_false_multi_sparse_2.html
diff --git a/pandas/tests/io/formats/data/render_links_false.html b/pandas/tests/io/formats/data/html/render_links_false.html
similarity index 100%
rename from pandas/tests/io/formats/data/render_links_false.html
rename to pandas/tests/io/formats/data/html/render_links_false.html
diff --git a/pandas/tests/io/formats/data/render_links_true.html b/pandas/tests/io/formats/data/html/render_links_true.html
similarity index 100%
rename from pandas/tests/io/formats/data/render_links_true.html
rename to pandas/tests/io/formats/data/html/render_links_true.html
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_multi.html
new file mode 100644
index 00000000000000..e66d3c816e67d2
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_multi.html
@@ -0,0 +1,88 @@
+
+
+
+ |
+ |
+ foo |
+ a |
+ ... |
+ b |
+
+
+ |
+ |
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ |
+ baz |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+ foo |
+ |
+ baz |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_standard.html
new file mode 100644
index 00000000000000..536b371145081f
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_named_standard.html
@@ -0,0 +1,72 @@
+
+
+
+ |
+ |
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ foo |
+ |
+ baz |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..d472cdecb12c9e
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_multi.html
@@ -0,0 +1,88 @@
+
+
+
+ |
+ |
+ |
+ a |
+ ... |
+ b |
+
+
+ |
+ |
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ |
+ |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+ foo |
+ |
+ baz |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..31c71ca3e59f6b
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_multi_columns_unnamed_standard.html
@@ -0,0 +1,72 @@
+
+
+
+ |
+ |
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ foo |
+ |
+ baz |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_multi.html
new file mode 100644
index 00000000000000..779e84f6ee6d1e
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_multi.html
@@ -0,0 +1,74 @@
+
+
+
+ foo |
+ a |
+ ... |
+ b |
+
+
+ |
+ c |
+ ... |
+ d |
+
+
+ baz |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+ index.name |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_standard.html
new file mode 100644
index 00000000000000..b86454f5fb11f5
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_named_standard.html
@@ -0,0 +1,62 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ index.name |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..24b776e18bef9c
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_multi.html
@@ -0,0 +1,74 @@
+
+
+
+ |
+ a |
+ ... |
+ b |
+
+
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+ index.name |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..a0ca960207ac00
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_named_standard_columns_unnamed_standard.html
@@ -0,0 +1,62 @@
+
+
+
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ index.name |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_multi.html
new file mode 100644
index 00000000000000..6640db4cf87047
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_multi.html
@@ -0,0 +1,66 @@
+
+
+
+ foo |
+ a |
+ ... |
+ b |
+
+
+ |
+ c |
+ ... |
+ d |
+
+
+ baz |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_standard.html
new file mode 100644
index 00000000000000..364a0b98d6548c
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_named_standard.html
@@ -0,0 +1,54 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_none.html b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_none.html
new file mode 100644
index 00000000000000..e2af1ba42e940a
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_none.html
@@ -0,0 +1,39 @@
+
+
+
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..8c9a9e244277bd
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_multi.html
@@ -0,0 +1,58 @@
+
+
+
+ a |
+ ... |
+ b |
+
+
+ c |
+ ... |
+ d |
+
+
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..b9dcf526194909
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_none_columns_unnamed_standard.html
@@ -0,0 +1,48 @@
+
+
+
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_multi.html
new file mode 100644
index 00000000000000..0590d0dea66696
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_multi.html
@@ -0,0 +1,78 @@
+
+
+
+ |
+ |
+ foo |
+ a |
+ ... |
+ b |
+
+
+ |
+ |
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ |
+ baz |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_standard.html
new file mode 100644
index 00000000000000..28a2d964675a3a
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_named_standard.html
@@ -0,0 +1,62 @@
+
+
+
+ |
+ |
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_none.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_none.html
new file mode 100644
index 00000000000000..387ac51b176349
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_none.html
@@ -0,0 +1,50 @@
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..30cd85904be4e0
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_multi.html
@@ -0,0 +1,78 @@
+
+
+
+ |
+ |
+ |
+ a |
+ ... |
+ b |
+
+
+ |
+ |
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ |
+ |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..81edece2204089
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_multi_columns_unnamed_standard.html
@@ -0,0 +1,62 @@
+
+
+
+ |
+ |
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ a |
+ c |
+ e |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ f |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ b |
+ d |
+ e |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ f |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_multi.html
new file mode 100644
index 00000000000000..2acacfed3a6d0f
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_multi.html
@@ -0,0 +1,66 @@
+
+
+
+ foo |
+ a |
+ ... |
+ b |
+
+
+ |
+ c |
+ ... |
+ d |
+
+
+ baz |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_standard.html
new file mode 100644
index 00000000000000..c9bacdbd241a67
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_named_standard.html
@@ -0,0 +1,54 @@
+
+
+
+ columns.name |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_none.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_none.html
new file mode 100644
index 00000000000000..f2696f7d6b46a1
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_none.html
@@ -0,0 +1,44 @@
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_multi.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_multi.html
new file mode 100644
index 00000000000000..37e731520c7d91
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_multi.html
@@ -0,0 +1,66 @@
+
+
+
+ |
+ a |
+ ... |
+ b |
+
+
+ |
+ c |
+ ... |
+ d |
+
+
+ |
+ e |
+ f |
+ ... |
+ e |
+ f |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_standard.html b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_standard.html
new file mode 100644
index 00000000000000..3241ff41c5c581
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/trunc_df_index_unnamed_standard_columns_unnamed_standard.html
@@ -0,0 +1,54 @@
+
+
+
+ |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+
+
+ 0 |
+ 0 |
+ 1 |
+ ... |
+ 6 |
+ 7 |
+
+
+ 1 |
+ 8 |
+ 9 |
+ ... |
+ 14 |
+ 15 |
+
+
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+ ... |
+
+
+ 6 |
+ 48 |
+ 49 |
+ ... |
+ 54 |
+ 55 |
+
+
+ 7 |
+ 56 |
+ 57 |
+ ... |
+ 62 |
+ 63 |
+
+
+
diff --git a/pandas/tests/io/formats/data/truncate.html b/pandas/tests/io/formats/data/html/truncate.html
similarity index 100%
rename from pandas/tests/io/formats/data/truncate.html
rename to pandas/tests/io/formats/data/html/truncate.html
diff --git a/pandas/tests/io/formats/data/truncate_multi_index.html b/pandas/tests/io/formats/data/html/truncate_multi_index.html
similarity index 100%
rename from pandas/tests/io/formats/data/truncate_multi_index.html
rename to pandas/tests/io/formats/data/html/truncate_multi_index.html
diff --git a/pandas/tests/io/formats/data/truncate_multi_index_sparse_off.html b/pandas/tests/io/formats/data/html/truncate_multi_index_sparse_off.html
similarity index 100%
rename from pandas/tests/io/formats/data/truncate_multi_index_sparse_off.html
rename to pandas/tests/io/formats/data/html/truncate_multi_index_sparse_off.html
diff --git a/pandas/tests/io/formats/data/unicode_1.html b/pandas/tests/io/formats/data/html/unicode_1.html
similarity index 100%
rename from pandas/tests/io/formats/data/unicode_1.html
rename to pandas/tests/io/formats/data/html/unicode_1.html
diff --git a/pandas/tests/io/formats/data/unicode_2.html b/pandas/tests/io/formats/data/html/unicode_2.html
similarity index 100%
rename from pandas/tests/io/formats/data/unicode_2.html
rename to pandas/tests/io/formats/data/html/unicode_2.html
diff --git a/pandas/tests/io/formats/data/with_classes.html b/pandas/tests/io/formats/data/html/with_classes.html
similarity index 100%
rename from pandas/tests/io/formats/data/with_classes.html
rename to pandas/tests/io/formats/data/html/with_classes.html
diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py
index 6c2d12076a2629..eb11433f46c0e1 100644
--- a/pandas/tests/io/formats/test_to_html.py
+++ b/pandas/tests/io/formats/test_to_html.py
@@ -29,7 +29,7 @@ def expected_html(datapath, name):
str : contents of HTML file.
"""
filename = '.'.join([name, 'html'])
- filepath = datapath('io', 'formats', 'data', filename)
+ filepath = datapath('io', 'formats', 'data', 'html', filename)
with open(filepath, encoding='utf-8') as f:
html = f.read()
return html.rstrip()
@@ -414,6 +414,96 @@ def test_to_html_multiindex_max_cols(self, datapath):
expected = expected_html(datapath, 'gh6131_expected_output')
assert result == expected
+ def test_to_html_multi_indexes_index_false(self, datapath):
+ # GH 22579
+ df = DataFrame({'a': range(10), 'b': range(10, 20), 'c': range(10, 20),
+ 'd': range(10, 20)})
+ df.columns = MultiIndex.from_product([['a', 'b'], ['c', 'd']])
+ df.index = MultiIndex.from_product([['a', 'b'],
+ ['c', 'd', 'e', 'f', 'g']])
+ result = df.to_html(index=False)
+ expected = expected_html(datapath, 'gh22579_expected_output')
+ assert result == expected
+
+ @pytest.mark.parametrize('index_names', [True, False])
+ @pytest.mark.parametrize('index', [True, False])
+ @pytest.mark.parametrize('column_index, column_type', [
+ (Index([0, 1]), 'unnamed_standard'),
+ (Index([0, 1], name='columns.name'), 'named_standard'),
+ (MultiIndex.from_product([['a'], ['b', 'c']]), 'unnamed_multi'),
+ (MultiIndex.from_product(
+ [['a'], ['b', 'c']], names=['columns.name.0',
+ 'columns.name.1']), 'named_multi')
+ ])
+ @pytest.mark.parametrize('row_index, row_type', [
+ (Index([0, 1]), 'unnamed_standard'),
+ (Index([0, 1], name='index.name'), 'named_standard'),
+ (MultiIndex.from_product([['a'], ['b', 'c']]), 'unnamed_multi'),
+ (MultiIndex.from_product(
+ [['a'], ['b', 'c']], names=['index.name.0',
+ 'index.name.1']), 'named_multi')
+ ])
+ def test_to_html_basic_alignment(
+ self, datapath, row_index, row_type, column_index, column_type,
+ index, index_names):
+ # GH 22747, GH 22579
+ df = DataFrame(np.zeros((2, 2), dtype=int),
+ index=row_index, columns=column_index)
+ result = df.to_html(index=index, index_names=index_names)
+
+ if not index:
+ row_type = 'none'
+ elif not index_names and row_type.startswith('named'):
+ row_type = 'un' + row_type
+
+ if not index_names and column_type.startswith('named'):
+ column_type = 'un' + column_type
+
+ filename = 'index_' + row_type + '_columns_' + column_type
+ expected = expected_html(datapath, filename)
+ assert result == expected
+
+ @pytest.mark.parametrize('index_names', [True, False])
+ @pytest.mark.parametrize('index', [True, False])
+ @pytest.mark.parametrize('column_index, column_type', [
+ (Index(np.arange(8)), 'unnamed_standard'),
+ (Index(np.arange(8), name='columns.name'), 'named_standard'),
+ (MultiIndex.from_product(
+ [['a', 'b'], ['c', 'd'], ['e', 'f']]), 'unnamed_multi'),
+ (MultiIndex.from_product(
+ [['a', 'b'], ['c', 'd'], ['e', 'f']], names=['foo', None, 'baz']),
+ 'named_multi')
+ ])
+ @pytest.mark.parametrize('row_index, row_type', [
+ (Index(np.arange(8)), 'unnamed_standard'),
+ (Index(np.arange(8), name='index.name'), 'named_standard'),
+ (MultiIndex.from_product(
+ [['a', 'b'], ['c', 'd'], ['e', 'f']]), 'unnamed_multi'),
+ (MultiIndex.from_product(
+ [['a', 'b'], ['c', 'd'], ['e', 'f']], names=['foo', None, 'baz']),
+ 'named_multi')
+ ])
+ def test_to_html_alignment_with_truncation(
+ self, datapath, row_index, row_type, column_index, column_type,
+ index, index_names):
+ # GH 22747, GH 22579
+ df = DataFrame(np.arange(64).reshape(8, 8),
+ index=row_index, columns=column_index)
+ result = df.to_html(max_rows=4, max_cols=4,
+ index=index, index_names=index_names)
+
+ if not index:
+ row_type = 'none'
+ elif not index_names and row_type.startswith('named'):
+ row_type = 'un' + row_type
+
+ if not index_names and column_type.startswith('named'):
+ column_type = 'un' + column_type
+
+ filename = 'trunc_df_index_' + row_type + '_columns_' + column_type
+ expected = expected_html(datapath, filename)
+ assert result == expected
+
@pytest.mark.parametrize('index', [False, 0])
def test_to_html_truncation_index_false_max_rows(self, datapath, index):
# GH 15019
@@ -428,13 +518,20 @@ def test_to_html_truncation_index_false_max_rows(self, datapath, index):
assert result == expected
@pytest.mark.parametrize('index', [False, 0])
- def test_to_html_truncation_index_false_max_cols(self, datapath, index):
+ @pytest.mark.parametrize('col_index_named, expected_output', [
+ (False, 'gh22783_expected_output'),
+ (True, 'gh22783_named_columns_index')
+ ])
+ def test_to_html_truncation_index_false_max_cols(
+ self, datapath, index, col_index_named, expected_output):
# GH 22783
data = [[1.764052, 0.400157, 0.978738, 2.240893, 1.867558],
[-0.977278, 0.950088, -0.151357, -0.103219, 0.410599]]
df = DataFrame(data)
+ if col_index_named:
+ df.columns.rename('columns.name', inplace=True)
result = df.to_html(max_cols=4, index=index)
- expected = expected_html(datapath, 'gh22783_expected_output')
+ expected = expected_html(datapath, expected_output)
assert result == expected
def test_to_html_notebook_has_style(self):