code: def print_table(table,
                  name=None,
                  float_format=None,
                  formatters=None,
                  header_rows=None):
      
  
      if isinstance(table, pd.Series):
          table = pd.DataFrame(table)
  
      if name is not None:
          table.columns.name = name
  
      html = table.to_html(float_format=float_format, formatters=formatters)
  
      if header_rows is not None:
          # Count the number of columns for the text to span
          n_cols = html.split('<thead>')[1].split('</thead>')[0].count('<th>')
  
          # Generate the HTML for the extra rows
          rows = ''
          for name, value in header_rows.items():
              rows += ('\n    <tr style="text-align: right;"><th>%s</th>' +
                       '<td colspan=%d>%s</td></tr>') % (name, n_cols, value)
  
          # Inject the new HTML
          html = html.replace('<thead>', '<thead>' + rows)
  
      display(HTML(html))
docs: 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.