Turtle Island: A Utility Kit for Polars Expressions

python
polars
ti
Author

Jerry Wu

Published

July 6, 2025

This weekend, I started building a Python package called Turtle Island, which collects some of my ideas for helper functions aimed at reducing boilerplate when writing Polars expressions.

Currently, Turtle Island offers the following nine utilities:

Here’s a quick example that uses ti.is_every_nth_row() to build a Polars expression suitable for styling tables interactively with Great Tables:

import polars as pl
from great_tables import GT, loc, style
from great_tables.data import countrypops

import turtle_island as ti

df_pd = countrypops.sample(10).loc[:, ["country_name", "year", "population"]]
df_pl = pl.from_pandas(df_pd)
row_expr = ti.is_every_nth_row(3)

(
    GT(df_pl)
    .tab_style(style=style.fill("lightblue"), locations=loc.body(rows=row_expr))
    .tab_style(style=style.fill("papayawhip"), locations=loc.body(rows=~row_expr))
    .opt_stylize(style=3, color="pink")
)

Styling table using Turtle Island

Disclaimer

This post was drafted by me, with AI assistance to refine the content.