python - HTML IDs for rows of a Pandas Dataframe.to_html() output -
i'm trying style rows of pandas dataframe way (depending on external factor) using df.to_html() , css rules, there way give rows html ids using pandas, or have deal raw html output of to_html().
more details: have pandas dataframe result of sql query. compared previous query results , table sent out email. want highlight rows of dataframe new. i'm thinking of doing inserting css rules either apply ids of specific rows in resultant html table, or attaching class these rows.
you can use .to_html() classes keyword (see docs) attach classes <table></table> tag. if need id instead of class, fix output df.to_html(classes='my_class').replace('class', 'id').
with brand new version 0.17.1, pandas received conditional html formatting allows more fine-grained layout control - under development: see docs..
in particular, slicing functionality sounds looking highlight specific rows. ipython notebook documentation , interactive examples: here
for more complicated adjustments beyond <table> level there beautifulsoup, that's of course ex-post , not part of pandas.
Comments
Post a Comment