Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improve HTML styling of Pandas DataFrames within IPython widgets

How can I generate appropriate HTML to hand to an ipywidgets.HTML object to properly display a Pandas DataFrame?

enter image description here

like image 865
MRocklin Avatar asked Mar 03 '16 18:03

MRocklin


1 Answers

This can be achieved with the lovely new DataFrame.style class.

For example

enter image description here

This example depends on bootstrap's CSS being loaded on the page. It's included in the notebook when you're running the notebook interactively.

More generally a mixture of set_table_attributes to give it a class, and set_table_styles for more specific items should give pretty fine-grained controls.

like image 128
TomAugspurger Avatar answered Sep 27 '22 23:09

TomAugspurger