Polars: pandas at Warp Speed

Pandas made Python the language of data — and then showed its age. Polars is the rewrite: multi-threaded, query-planned, and 10-50x faster on the workloads agents actually generate.

▶ Watch this reel

What you'll learn

  1. Why Polars wins
  2. The expression API
  3. Lazy queries
  4. When to switch

Remember this

Why it wins

Expressions

Lazy

When to switch

Cross-links

AG-19 (lazy → collect_async in async services), AG-21 (eval datasets), AG-23 (token accounting feeds cost model), GA-20 (SLO analysis), GA-25/30 (cost pipelines).

Code: The agent-data one-liner set

import polars as pl

# 80% of GenAI data work is these four:

logs = pl.scan_ndjson("runs/*.jsonl")

costs = logs.group_by("model").agg(
    (pl.col("in") + pl.col("out")).sum().alias("tokens")
)                                   # 1 · token accounting (AG-23)

quality = logs.with_columns(
    pl.when(pl.col("score") >= 0.92).then("pass")
      .otherwise("fail").alias("v")
).group_by(["model", "v"]).agg(pl.len())   # 2 · SLO verdicts (GA-20)

slow = logs.filter(pl.col("ms") > 3000)    # 3 · latency outliers (GA-07)

query = logs.select(pl.col("prompt").str.extract(r"Goal: (.*?)")
        .alias("goal")).unique()            # 4 · prompt mining

# .collect() when ready. No loops were harmed.