79280524

Date: 2024-12-14 11:21:43
Score: 0.5
Natty:
Report link

You were pretty close in your last snippet! For the locations argument to accept a list, it needs to be done in a list comprehension, or ahead of time, outside the tab_style method call.

import polars as pl
from great_tables import GT, style, loc

# define `gt_sample_df` as per example snippet

required_columns = gt_sample_df.drop("Test",'Lower Range','Upper Range').columns

(
    GT(gt_sample_df)
    .tab_style(
        style=[style.text(color="Navy"), style.fill(color="PaleTurquoise")],
        locations=[
            loc.body(columns=col_name, rows=pl.col(col_name) > pl.col("Upper Range"))
            for col_name in required_columns
        ]
    )
)

great table output

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Henry Harbeck