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
]
)
)