FormingSkillclaude-codepublished fresh until

Can my agent translate pandas code to Polars correctly?

Summary Polars' own test of Claude Opus 4.8 found 31 of 33 pandas-to-Polars translations worked, with leftover pandas habits like aggregate-then-join-back. Polars publishes an agent skill (MIT) and a docs MCP server; its team says to verify every translation with assert_frame_equal.

Not for pandas out of memory on a big CSV

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0polars skill (Polars team)
How you use itYou ask for it
What it can doinstalls software · writes files
What's inside
ASkill · v1.0.0polars skill (Polars team)
How you use it
You ask for it
What it can do
installs software · writes files
What's inside

What this thread does

The problem

You ask an agent for Polars and it writes pandas, or it writes Polars with old names (groupby instead of group_by) or pandas-style detours. The Polars docs page on LLMs confirms models often return pandas or invalid Polars code.

What the Polars team measured

Thijs Nieuwdorp of Polars published "Fluent, not native: agents translating pandas to Polars" on 25 June 2026. Method as described: Claude Opus 4.8 translated 33 pandas cases (22 PDS-H benchmark queries and 11 exploratory data analysis cases), one shot each in a fresh session, with the outputs compared by assert_frame_equal. Results:

  • Opus: 31 of 33 correct; the two failures were minor (a missing import, a wrong column reference). Sonnet 4.6 got 33 of 33 right but wrote more non-idiomatic code.
  • Patterns models still get wrong: aggregate then join back instead of a window .over() (3 of 33 cases); a mid-pipeline .item() that forces an early collect() (1 case); writing pl.col("x").sum() rather than pl.sum("x") inside .agg() (48 times, style only). Sonnet used list-wrapped arguments in 21 of 33 cases.
  • With the official skill installed: Opus correct 31 to 32 of 33, join-back cases 3 to 1, .item() 1 to 0; Sonnet's wrong-pattern count fell from 80 to 23.
  • The author calls it directional: one run per case, one model family, and it comes from the vendor.

What to do

1. Install the skill. From the post: in Claude Code run /plugin marketplace add polars-inc/skills then /plugin install polars@polars, or copy the skill by hand. The repo (polars-inc/skills, MIT, last pushed 26 Oct 2026) is small; read it before installing. 2. Or add the docs MCP server: the Polars docs list https://mcp.pola.rs/mcp (the docs show an npx mcp-remote config and say to check your client's documentation for Claude Code steps). 3. Say it in the prompt: "Use Polars as the default dataframe library", ask for group_by not groupby, and include one short example from the official docs. The docs say web search helps but does not guarantee valid code. 4. Verify each translation: run the old and new code on the same input and compare with polars.testing.assert_frame_equal (convert the pandas result first). This is the post's first recommendation. 5. Review for the known habits: use .over() for per-group values, keep scalars inside expressions instead of .item(), pass positional arguments instead of lists, and swap map_elements dictionary lookups for replace_strict (the post measured about 19 times faster at 5M rows). Run with warnings visible; PolarsInefficientMapWarning names replacements.

Common mistakes

  • Treating "it ran" as "it is equal": order, dtypes and null handling can differ. Compare frames.
  • Skipping the review for pandas habits: the post found the working-but-unidiomatic patterns above, and a literal translation keeps them (my reading, not a measured slowdown).

Caveats

I have not run the skill myself. The numbers are one vendor test; the Polars docs page also notes that web search does not guarantee valid code. Pandera (see the validation thread) can also check Polars frames.

Started from a post by @Thijs Nieuwdorp, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Can my agent translate pandas code to Polars correctly?
Summary: Polars' own test of Claude Opus 4.8 found 31 of 33 pandas-to-Polars translations worked, with leftover pandas habits like aggregate-then-join-back. Polars publishes an agent skill (MIT) and a docs MCP server; its team says to verify every translation with assert_frame_equal.

## Options
- A · polars skill (Polars team) · early, no verdict yet · installs software · writes files
Copy for agent
get the whatworks thread translate-pandas-to-polars-with-agent-polars-skill and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread translate-pandas-to-polars-with-agent-polars-skill

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · polars skill (Polars team)

The Polars team's own skill: lazy-API guidance, expression and context references, insight recipes and a pandas-to-Polars translation table (window .over() instead of aggregate-then-join-back, positional args instead of list form).

Format
Skill
Source
github:polars-inc/skills#polars
Pinned
v1.0.0 · 70bec73cd097
Content hash
70bec73cd0972241
Audit
scan passed
Can do
installs software · writes files
Works with
claude-code
Check
Skill installed in the project; SKILL.md front matter names the skill; pandas-to-Polars table carries the window-function rule (aggregate-and-join-back replaced by over); Lazy API reference present
Author
@polars-inc
Kudos
0
Are you @polars-inc? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package polars-skill before installing

A · Files

Read from the package source at the pinned version. Shown as is; nothing here runs.

Loading files…

Ask your agent
show me the files of the whatworks package polars-skill
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp