diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py index 967e5fca5f711..bc2de210df3f4 100644 --- a/pandas/io/formats/html.py +++ b/pandas/io/formats/html.py @@ -78,7 +78,7 @@ def _write_cell(self, s, kind='td', indent=0, tags=None): self.write(u'{start}{rs}' .format(start=start_tag, rs=rs, kind=kind), indent) - def write_tr(self, line, indent=0, indent_delta=4, header=False, + def write_tr(self, line, indent=0, indent_delta=0, header=False, align=None, tags=None, nindex_levels=0): if tags is None: tags = {} @@ -200,26 +200,6 @@ def _write_header(self, indent): # write nothing return indent - def _column_header(): - if self.fmt.index: - row = [''] * (self.frame.index.nlevels - 1) - else: - row = [] - - if isinstance(self.columns, ABCMultiIndex): - if self.fmt.has_column_names and self.fmt.index: - row.append(single_column_table(self.columns.names)) - else: - row.append('') - style = "text-align: {just};".format(just=self.fmt.justify) - row.extend([single_column_table(c, self.fmt.justify, style) - for c in self.columns]) - else: - if self.fmt.index: - row.append(self.columns.name or '') - row.extend(self.columns) - return row - self.write('', indent) indent += self.indent_delta @@ -301,16 +281,21 @@ def _column_header(): self.write_tr(row, indent, self.indent_delta, tags=tags, header=True) else: - col_row = _column_header() + if self.fmt.index: + row = [''] * (self.frame.index.nlevels - 1) + row.append(self.columns.name or '') + else: + row = [] + 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 - col_row.insert(ins_col, '...') + row.insert(ins_col, '...') - self.write_tr(col_row, indent, self.indent_delta, header=True, + self.write_tr(row, indent, self.indent_delta, header=True, align=align) if all((self.fmt.has_index_names, @@ -486,24 +471,3 @@ def _write_hierarchical_rows(self, fmt_values, indent): row.insert(row_levels + self.fmt.tr_col_num, '...') self.write_tr(row, indent, self.indent_delta, tags=None, nindex_levels=frame.index.nlevels) - - -def single_column_table(column, align=None, style=None): - table = '{i!s}'.format(i=i)) - table += '' - return table - - -def single_row_table(row): # pragma: no cover - table = '' - for i in row: - table += (''.format(i=i)) - table += '
{i!s}
' - return table