Skip to content

BUG: User-facing AssertionError with DataFrame.to_html(classes=<invalid type>) #25608

Closed
@simonjayhawkins

Description

@simonjayhawkins

Code Sample, a copy-pastable example if possible

import pandas as pd
pd.DataFrame().to_html(classes=True)

Problem description

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\frame.py", line 2212, in to_html
    formatter.to_html(classes=classes, notebook=notebook, border=border)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\format.py", line 729, in to_html
    html = Klass(self, classes=classes, border=border).render()
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\html.py", line 146, in render
    self._write_table()
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\html.py", line 167, in _write_table
    .format(typ=type(self.classes)))
AssertionError: classes must be list or tuple, not <class 'bool'>

Expected Output

TypeError: classes must be a string, list or tuple, not <class 'bool'>

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasIO HTMLread_html, to_html, Styler.apply, Styler.applymapgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions