ml4t-polars-patterns

Installation
SKILL.md

Polars Patterns for Quant Finance

Pandas groupby-apply with Python functions is 10-100x slower than Polars lazy expressions with .over(). For financial data - where most operations are per-symbol rolling computations - the performance gap determines whether your pipeline takes minutes or hours.

The Problem

A typical quant workflow: load 500 symbols of daily data (2M rows), compute 20-day rolling features per symbol, cross-sectional rank, then join with labels. In pandas with groupby().apply(), this takes 45 seconds and 8 GB of RAM. The same logic in Polars lazy mode takes 2 seconds and 800 MB. The difference is not optimization - it is a fundamentally different execution model.

The Pattern

WRONG

import pandas as pd

# Pandas: iterative groupby-apply - Python loop per group
df = pd.read_parquet("prices.parquet")
Installs
17
Repository
ml4t/skills
GitHub Stars
39
First Seen
Sep 13, 2026