You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to figure out how to do a seemingly simple data colorization:
I need cell backgrounds of all numeric columns to be green, if the value is >= 1.1; red, if the value is <= 0.9; and white otherwise (only these 3 colors, no gradients).
data_color() seems close, however, I can't figure out how to implement the above.
The best I was able to come up with is this:
from polars import col
...
gt = df.style
for c in numeric_columns:
gt = gt.tab_style(
style=style.fill(color='lightgreen'),
locations=loc.body(columns=c, rows=col(c) > 1.05)
)
gt = gt.tab_style(
style=style.fill(color='lightpink'),
locations=loc.body(columns=c, rows=col(c) < 0.95)
)
However, this code seems way too verbose. Is there a simpler way?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to figure out how to do a seemingly simple data colorization:
I need cell backgrounds of all numeric columns to be green, if the value is >= 1.1; red, if the value is <= 0.9; and white otherwise (only these 3 colors, no gradients).
data_color()
seems close, however, I can't figure out how to implement the above.The best I was able to come up with is this:
However, this code seems way too verbose. Is there a simpler way?
Beta Was this translation helpful? Give feedback.
All reactions