polars

Process in-memory DataFrames with lazy evaluation, parallel execution, and Apache Arrow backend.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill polars-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: polars
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/polars
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill polars-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires polars, and includes references (resource) components.

What problem does it solve? Pandas becomes slow and memory-hungry on datasets in the 1-100GB range, forcing trade-offs between performance and convenience. This Skill provides guidance for using Polars, a DataFrame library built on Apache Arrow with lazy evaluation and automatic parallelization, as a faster pandas replacement for data that still fits in RAM. ## Core Features & Use Cases - Expression-Based Transformations: Build composable operations with select, filter, with_columns, group_by aggregations, and window functions using the over() clause. - Lazy Query Optimization: Use scan_csv/scan_parquet with LazyFrame to get predicate pushdown, projection pushdown, and streaming execution for large files. - Pandas Migration: Apply operation mappings and anti-pattern guidance to convert existing pandas code to Polars syntax. - Use Case: You have a 20GB CSV of transaction logs. Instead of loading it eagerly, use pl.scan_csv, filter and aggregate lazily, then collect with streaming enabled to stay within memory limits. ## Quick Start Ask the AI to convert a pandas filtering and groupby script into an optimized Polars lazy query using scan_csv and collect.

Frequently Asked Questions about polars

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate pandas code to Polars?

Replace df["col"] with df.select("col"), boolean indexing with df.filter(pl.col("x") > 10), df.assign with df.with_columns, and groupby().transform() with aggregations using .over("group"). Polars has no index, so remove set_index and reset_index calls.

When should I use Polars lazy evaluation vs eager?

Use lazy evaluation (scan_csv, LazyFrame) for large datasets, complex pipelines, or when only some columns and rows are needed, since it enables predicate and projection pushdown. Use eager DataFrames for small data and interactive exploration.

Polars vs pandas: which is faster for large datasets?

Polars is generally faster due to its Apache Arrow columnar backend, automatic parallelization, and query optimization in lazy mode. It suits 1-100GB datasets that fit in RAM; for larger-than-RAM data, consider dask or vaex instead.

Does Polars support reading from S3 and databases?

Yes. Polars reads and writes Parquet and other formats directly from S3, Azure Blob, and Google Cloud Storage using URI paths with environment credentials. It also queries PostgreSQL, MySQL, and SQLite via read_database_uri.

Why is my Polars code slow with map_elements?

Python functions passed to map_elements disable parallelization and run sequentially. Rewrite the logic using native Polars expressions like arithmetic on pl.col() or when/then/otherwise, which execute in parallel across threads.

How do I process files larger than RAM in Polars?

Use lazy mode with streaming: call pl.scan_csv or pl.scan_parquet, build your query, then run collect(streaming=True) to process data in chunks. Alternatively, use sink_parquet to stream results directly to disk.