-
I want to add a color palette where the "winner" for each row (lowest MAE) is highlighted for every row. My current code: error_metrics = (stack_filtered
.group_by("customer_group", "Forecast")
.agg(
pl.col("error").abs().mean().alias("MAE"),
)
.pivot(
values=["MAE"],
index="customer_group",
on="Forecast"
)
.sort("customer_group"))
# Rename columns to remove the metric prefix
renamed_columns = {
'MAE_Standard': 'Standard',
'MAE_Custom': 'Custom',
}
GT(
error_metrics, rowname_col="customer_group"
).cols_label(
renamed_columns
).tab_spanner(
label="Mean Absolute Error",
columns=[col for col in error_metrics.columns if 'MAE' in col]
).data_color(
domain=[0, 500],
palette=["rebeccapurple", "white", "orange"],
na_color="white",
).tab_header(
title="Forecast Error Metrics by Customer Group",
subtitle="Comparison of MAE across different forecasters"
).fmt_number(
columns=[col for col in error_metrics.columns if col != "customer_group"],
decimals=2
) |
Beta Was this translation helpful? Give feedback.
Answered by
jrycw
Mar 12, 2025
Replies: 1 comment
-
Related issue: #601. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lucharo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related issue: #601.