Issue
I'm using a jupyter like platform that has truly terrible visual capabilities and one of the annoying things is that when simply seeing a dataframe by having it be the last thing in a cell all the usual pandas formatting is gone if I turn it into a styler.
What I mean by that is:
- alternating rows white / grey
- hover over row gets me nothing instead of that blue highlighting
- numbers are aligned in weird ways
I want to use styler because it allows me to format numbers easily (ie things like '{:,.0f}'
or '{:.1%}'
.
Is there a way to force the formatting to match the "default" in some easy way? eg where is the default stored?
df # this works fine as an output
df.style # this loses all default formatting
Solution
Some editors rely on CSS classes to apply their own browser specific styling.
At one time google colab refused to auto format a Styler since DataFrame HTML adds the dataframe class in <table class="dataframe">
, whereas Styler doesnt.
Try using df.style.set_table_attributes('class="dataframe"')
Answered By - Attack68
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.