Home Applying styling to Pandas dataframe saved to HTML file
Reply: 0

Applying styling to Pandas dataframe saved to HTML file

user961
1#
user961 Published in July 22, 2018, 5:52 pm

I have a Pandas dataframe inside of a Jupyter / IPython notebook. The dataframe's style as an HTML table inside of Jupyter is pretty nice. The header row has bold style, the font is nice, and the table borders are thin.

I then export the dataframe to an HTML file (following instructions here and here):

df.to_html('myfile.html')

But the resulting HTML file's table styling is not good.

The HTML in that file is plain:

<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Id</th>
      <th>Index</th>
      <th>Feature</th>
      <th>Timestamp</th>
      <th>Feature2</th>
    </tr>
  </thead>

How do I modify the styling of this exported table directly from my Python / Pandas code?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308416 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO