# Buggy code
def _write_body(self, indent):
    self.write("<tbody>", indent)
    indent += self.indent_delta

    fmt_values = {}
    for i in range(min(len(self.columns), self.max_cols)):
        fmt_values[i] = self.fmt._format_col(i)

    # write values
    if self.fmt.index:
        if isinstance(self.frame.index, MultiIndex):
            self._write_hierarchical_rows(fmt_values, indent)
        else:
            self._write_regular_rows(fmt_values, indent)
    else:
        for i in range(len(self.frame)):
            row = [fmt_values[j][i] for j in range(len(self.columns))]
            self.write_tr(row, indent, self.indent_delta, tags=None)

    indent -= self.indent_delta
    self.write("</tbody>", indent)
    indent -= self.indent_delta

    return indent


# Traceback (IndexError)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-7-c16b7151f39c> in <module>()
----> 1 df.to_html(max_rows=10, index=False)

/Users/tom.augspurger/Envs/py3/lib/python3.6/site-packages/pandas-0.19.0+265.gaba7d255a-py3.6-macosx-10.12-x86_64.egg/pandas/core/frame.py in to_html(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, bold_rows, classes, escape, max_rows, max_cols, show_dimensions, notebook, decimal, border)
1553                                            decimal=decimal)
1554         # TODO: a generic formatter wld b in DataFrameFormatter
-> 1555         formatter.to_html(classes=classes, notebook=notebook, border=border)
1556
1557         if buf is None:

/Users/tom.augspurger/Envs/py3/lib/python3.6/site-packages/pandas-0.19.0+265.gaba7d255a-py3.6-macosx-10.12-x86_64.egg/pandas/formats/format.py in to_html(self, classes, notebook, border)
698                                       border=border)
699         if hasattr(self.buf, 'write'):
--> 700             html_renderer.write_result(self.buf)
701         elif isinstance(self.buf, compat.string_types):
702             with open(self.buf, 'w') as f:

/Users/tom.augspurger/Envs/py3/lib/python3.6/site-packages/pandas-0.19.0+265.gaba7d255a-py3.6-macosx-10.12-x86_64.egg/pandas/formats/format.py in write_result(self, buf)
1022         indent += self.indent_delta
1023         indent = self._write_header(indent)
-> 1024         indent = self._write_body(indent)
1025
1026         self.write('</table>', indent)

/Users/tom.augspurger/Envs/py3/lib/python3.6/site-packages/pandas-0.19.0+265.gaba7d255a-py3.6-macosx-10.12-x86_64.egg/pandas/formats/format.py in _write_body(self, indent)
1184         else:
1185             for i in range(len(self.frame)):
-> 1186                 row = [fmt_values[j][i] for j in range(len(self.columns))]
1187                 self.write_tr(row, indent, self.indent_delta, tags=None)
1188

/Users/tom.augspurger/Envs/py3/lib/python3.6/site-packages/pandas-0.19.0+265.gaba7d255a-py3.6-macosx-10.12-x86_64.egg/pandas/formats/format.py in <listcomp>(.0)
1184         else:
1185             for i in range(len(self.frame)):
-> 1186                 row = [fmt_values[j][i] for j in range(len(self.columns))]
1187                 self.write_tr(row, indent, self.indent_delta, tags=None)
1188

IndexError: list index out of range

# Fixed code
def _write_body(self, indent):
    self.write("<tbody>", indent)
    indent += self.indent_delta

    fmt_values = {}
    for i in range(min(len(self.columns), self.max_cols)):
        fmt_values[i] = self.fmt._format_col(i)

    # write values
    if self.fmt.index:
        if isinstance(self.frame.index, MultiIndex):
            self._write_hierarchical_rows(fmt_values, indent)
        else:
            self._write_regular_rows(fmt_values, indent)
    else:
        for i in range(min(len(self.frame), self.max_rows)):
            row = [fmt_values[j][i] for j in range(len(self.columns))]
            self.write_tr(row, indent, self.indent_delta, tags=None)

    indent -= self.indent_delta
    self.write("</tbody>", indent)
    indent -= self.indent_delta

    return indent