def print_table(table,<EOL>name=None,<EOL>float_format=None,<EOL>formatters=None,<EOL>header_rows=None):
if isinstance(table, pd.Series):<EOL><INDENT>table = pd.DataFrame(table)<EOL><DEDENT>if name is not None:<EOL><INDENT>table.columns.name = name<EOL><DEDENT>html = table.to_html(float_format=float_format, formatters=formatters)<EOL>if header_rows is not None:<EOL><INDENT>n_cols = html.split('<STR_LIT>')[<NUM_LIT:1>].split('<STR_LIT>')[<NUM_LIT:0>].count('<STR_LIT>')<EOL>rows = '<STR_LIT>'<EOL>for name, value in header_rows.items():<EOL><INDENT>rows += ('<STR_LIT>' +<EOL>'<STR_LIT>') % (name, n_cols, value)<EOL><DEDENT>html = html.replace('<STR_LIT>', '<STR_LIT>' + rows)<EOL><DEDENT>display(HTML(html))<EOL>
Pretty print a pandas DataFrame.

Uses HTML output if running inside Jupyter Notebook, otherwise
formatted text output.

Parameters
----------
table : pandas.Series or pandas.DataFrame
    Table to pretty-print.
name : str, optional
    Table name to display in upper left corner.
float_format : function, optional
    Formatter to use for displaying table elements, passed as the
    `float_format` arg to pd.Dataframe.to_html.
    E.g. `'{0:.2%}'.format` for displaying 100 as '100.00%'.
formatters : list or dict, optional
    Formatters to use by column, passed as the `formatters` arg to
    pd.Dataframe.to_html.
header_rows : dict, optional
    Extra rows to display at the top of the table.