0

How to use classes method in df.to_html()?

I have tried :

css_class = {'border-width': 'thin'}

df.to_html(index=False,classes=css_class)

I get an error : TypeError: sequence item 1: expected string, dict found

Example data:

df = DataFrame({'A':[1,1,2,3,5],'B':[3,4,5,6,7]})

I have to write this into an email. Now the output looks like:

enter image description here

How can I decrease the border width and make it a single lined border/thin border.

The df.to_html() documentation doesn't give an example.

Sharvari Gc
  • 691
  • 1
  • 11
  • 25
  • Pandas docs say: classes : str or list or tuple, you passed a dict. It applies already defined classes, so you only pass the classnames. – hootnot Jul 07 '18 at 10:25
  • take a look at: https://stackoverflow.com/questions/18096748/pandas-dataframes-to-html-highlighting-table-rows – hootnot Jul 07 '18 at 10:33

0 Answers0