Skip to content

Commit

Permalink
Using lightgrey for "posts/table-body-custom-palette"
Browse files Browse the repository at this point in the history
  • Loading branch information
jrycw committed Feb 25, 2025
1 parent 0d2b6c3 commit e38df4d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions posts/table-body-custom-palette/20250225.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In cases where colors need to be determined dynamically based on conditions, the
def color_selector(df_):
return df_["col1"].case_when(
[
(df_["col1"].lt(3), "lightgray"), # <3
(df_["col1"].lt(3), "lightgrey"), # <3
(df_["col1"].lt(10), "papayawhip"), # <10
(df_["col1"].ge(10), "lightblue"), # >=10
]
Expand Down Expand Up @@ -114,7 +114,7 @@ Alternatively, if you prefer sticking with the same approach, `pd.Series.case_wh
def color_selector(df_):
return df_["col2"].case_when(
[
(df_["col2"].eq("x"), "lightgray"),
(df_["col2"].eq("x"), "lightgrey"),
(df_["col2"].eq("y"), "papayawhip"),
(df_["col2"].eq("z"), "lightblue"),
]
Expand Down Expand Up @@ -168,7 +168,7 @@ For cases where colors need to be assigned dynamically, [pl.when()](https://docs
# | eval : False
color_selector_expr = (
pl.when(pl.col("col1").lt(3)) # <3
.then(pl.lit("lightgray"))
.then(pl.lit("lightgrey"))
.when(pl.col("col1").lt(10)) # <10
.then(pl.lit("papayawhip"))
.when(pl.col("col1").ge(10)) # >=10
Expand Down Expand Up @@ -203,7 +203,7 @@ Alternatively, if you prefer the conditional approach, `pl.when()` can still be
# | eval : False
color_selector_expr = (
pl.when(pl.col("col2").eq(pl.lit("x")))
.then(pl.lit("lightgray"))
.then(pl.lit("lightgrey"))
.when(pl.col("col2").eq(pl.lit("y")))
.then(pl.lit("papayawhip"))
.when(pl.col("col2").eq(pl.lit("z")))
Expand Down

0 comments on commit e38df4d

Please sign in to comment.